zed-industries/zed · error

Atomics.store failed

Error message

Atomics.store failed

What it means

In the web dispatcher's waker loop, an Atomics.store on shared memory failed — either SharedArrayBuffer semantics were violated (non-shared buffer, out-of-bounds index) or the environment changed between the capability check and use. Waking the main-thread mailbox will not work, so this signals a broken cross-thread wakeup path.

Source

Thrown at crates/gpui_web/src/dispatcher.rs:108

    }

    fn signal_view(&self) -> js_sys::Int32Array {
        let byte_offset = self.signal.as_ptr() as u32;
        let memory = js_sys::WebAssembly::Memory::from(wasm_bindgen::memory());
        js_sys::Int32Array::new_with_byte_offset_and_length(&memory.buffer(), byte_offset, 1)
    }

    fn run_waker_loop(self: &Arc<Self>, window: web_sys::Window) {
        if !shared_memory_supported() {
            log::warn!("SharedArrayBuffer not available; main thread mailbox waker loop disabled");
            return;
        }

        let mailbox = Arc::clone(self);
        wasm_bindgen_futures::spawn_local(async move {
            let view = mailbox.signal_view();
            loop {
                js_sys::Atomics::store(&view, 0, 0).expect("Atomics.store failed");

                // Items posted between the previous drain and the store above
                // set the signal we just cleared, so their notify is lost.
                // Drain again after re-arming to avoid missing them.
                mailbox.drain(&window);

                let result = match js_sys::Atomics::wait_async(&view, 0, 0) {
                    Ok(result) => result,
                    Err(error) => {
                        log::error!("Atomics.waitAsync failed: {error:?}");
                        break;
                    }
                };

                let is_async = js_sys::Reflect::get(&result, &JsValue::from_str("async"))
                    .ok()
                    .and_then(|v| v.as_bool())
                    .unwrap_or(false);

View on GitHub (pinned to f4178619ac)

Solutions

  1. Verify the buffer is a genuine SharedArrayBuffer and the index is in range
  2. Re-check shared_memory_supported() at use time, not only at loop start
  3. Ensure COOP/COEP headers keep SharedArrayBuffer available for the page
  4. Log and degrade to non-shared-memory wakeup if atomics fail
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/gpui_web/src/dispatcher.rs:108 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/a5a9eaf8cd4e8ad8. Report an issue: GitHub.