zed-industries/zed · error
failed to spawn background worker thread
Error message
failed to spawn background worker thread
What it means
Raised when wasm_thread::Builder::spawn fails while creating the i-th background worker thread in WebPlatform::new. This happens when the Web environment cannot start a Web Worker — e.g., missing thread/SharedArrayBuffer support, CSP blocking worker creation, or hitting the browser's worker limit. The dispatcher is left with fewer background workers than requested.
Source
Thrown at crates/gpui_web/src/dispatcher.rs:205
let mut receiver = background_receiver.clone();
wasm_thread::Builder::new()
.name(format!("background-worker-{i}"))
.spawn(move || {
loop {
let runnable: RunnableVariant = match receiver.pop() {
Ok(runnable) => runnable,
Err(_) => {
log::info!(
"background-worker-{i}: channel disconnected, exiting"
);
break;
}
};
runnable.run();
}
})
.expect("failed to spawn background worker thread")
})
.collect::<Vec<_>>()
} else {
Vec::new()
};
Self {
main_thread_id: std::thread::current().id(),
background_sender,
main_thread_mailbox,
supports_threads,
#[cfg(feature = "multithreaded")]
_background_threads: background_threads,
}
}
fn on_main_thread(&self) -> bool {
std::thread::current().id() == self.main_thread_idView on GitHub (pinned to f4178619ac)
Solutions
- Verify SharedArrayBuffer is available (COOP/COEP headers must be set cross-origin-isolation)
- Catch the spawn error per worker and continue with the workers that did spawn, falling back to single-threaded dispatch
- Check Content-Security-Policy worker-src directives if worker creation is blocked
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/gpui_web/src/dispatcher.rs:205 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/ce6e3681aafc056c.
Report an issue: GitHub.