{"record":{"id":"7db02b305b192d6c","repo":"zed-industries/zed","slug":"could-not-send-write-action-to-background-thread","errorCode":null,"errorMessage":"Could not send write action to background thread","messagePattern":"Could not send write action to background thread","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/sqlez/src/thread_safe_connection.rs","lineNumber":301,"sourceCode":"    use std::sync::mpsc::channel;\n\n    Box::new(|| {\n        let (sender, receiver) = channel::<QueuedWrite>();\n\n        thread::Builder::new()\n            .name(\"sqlezWorker\".to_string())\n            .spawn(move || {\n                while let Ok(write) = receiver.recv() {\n                    write()\n                }\n            })\n            .unwrap();\n\n        let sender = UnboundedSyncSender::new(sender);\n        Box::new(move |queued_write| {\n            sender\n                .send(queued_write)\n                .expect(\"Could not send write action to background thread\");\n        })\n    })\n}\n\npub fn locking_queue() -> WriteQueueConstructor {\n    Box::new(|| {\n        let write_mutex = Mutex::new(());\n        Box::new(move |queued_write| {\n            let _lock = write_mutex.lock();\n            queued_write();\n        })\n    })\n}\n\n#[cfg(test)]\nmod test {\n    use indoc::indoc;\n    use std::ops::Deref;","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/sqlez/src/thread_safe_connection.rs#L283-L319","documentation":"A panic in the sqlez background write queue: the worker thread's sender failed while enqueueing a write, meaning the sqlezWorker thread has exited (e.g. panicked earlier) while the connection is still open. Further writes cannot be persisted, so the caller aborts.","triggerScenarios":"Thrown at crates/sqlez/src/thread_safe_connection.rs:301 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rebuild the worker thread and channel when send fails","Avoid panics inside worker write callbacks that kill the thread","Propagate an error to the write caller"],"exampleFix":null,"handlingStrategy":"retry","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"}