{"record":{"id":"ce6e3681aafc056c","repo":"zed-industries/zed","slug":"failed-to-spawn-background-worker-thread","errorCode":null,"errorMessage":"failed to spawn background worker thread","messagePattern":"failed to spawn background worker thread","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_web/src/dispatcher.rs","lineNumber":205,"sourceCode":"                    let mut receiver = background_receiver.clone();\n                    wasm_thread::Builder::new()\n                        .name(format!(\"background-worker-{i}\"))\n                        .spawn(move || {\n                            loop {\n                                let runnable: RunnableVariant = match receiver.pop() {\n                                    Ok(runnable) => runnable,\n                                    Err(_) => {\n                                        log::info!(\n                                            \"background-worker-{i}: channel disconnected, exiting\"\n                                        );\n                                        break;\n                                    }\n                                };\n\n                                runnable.run();\n                            }\n                        })\n                        .expect(\"failed to spawn background worker thread\")\n                })\n                .collect::<Vec<_>>()\n        } else {\n            Vec::new()\n        };\n\n        Self {\n            main_thread_id: std::thread::current().id(),\n            background_sender,\n            main_thread_mailbox,\n            supports_threads,\n            #[cfg(feature = \"multithreaded\")]\n            _background_threads: background_threads,\n        }\n    }\n\n    fn on_main_thread(&self) -> bool {\n        std::thread::current().id() == self.main_thread_id","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/gpui_web/src/dispatcher.rs#L187-L223","documentation":"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.","triggerScenarios":"Thrown at crates/gpui_web/src/dispatcher.rs:205 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}