{"record":{"id":"00f56dc06299994e","repo":"zed-industries/zed","slug":"write-queue-unexpectedly-closed","errorCode":null,"errorMessage":"Write queue unexpectedly closed","messagePattern":"Write queue unexpectedly closed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/sqlez/src/thread_safe_connection.rs","lineNumber":189,"sourceCode":"        callback: impl 'static + Send + FnOnce(&Connection) -> T,\n    ) -> impl Future<Output = T> {\n        // Check and invalidate queue and maybe recreate queue\n        let queues = QUEUES.read();\n        let write_channel = queues\n            .get(&self.uri)\n            .expect(\"Queues are inserted when build is called. This should always succeed\");\n\n        // Create a one shot channel for the result of the queued write\n        // so we can await on the result\n        let (sender, receiver) = oneshot::channel();\n\n        let thread_safe_connection = (*self).clone();\n        write_channel(Box::new(move || {\n            let connection = thread_safe_connection.deref();\n            let result = connection.with_write(|connection| callback(connection));\n            sender.send(result).ok();\n        }));\n        receiver.map(|response| response.expect(\"Write queue unexpectedly closed\"))\n    }\n\n    pub(crate) fn create_connection(\n        persistent: bool,\n        uri: &str,\n        connection_initialize_query: Option<&'static str>,\n    ) -> Connection {\n        let mut connection = if persistent {\n            Self::open_file(uri)\n        } else {\n            Self::open_shared_memory(uri)\n        };\n\n        if let Some(initialize_query) = connection_initialize_query {\n            let mut last_error = None;\n            let initialized = (0..CONNECTION_INITIALIZE_RETRIES).any(|attempt| {\n                match connection\n                    .exec(initialize_query)","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/sqlez/src/thread_safe_connection.rs#L171-L207","documentation":"Invariant expect in sqlez ThreadSafeConnection::write(): the per-URI write queue is missing from the global queue map, though it is inserted at build time — the queue was removed/closed while a write was still being issued.","triggerScenarios":"Thrown at crates/sqlez/src/thread_safe_connection.rs:189 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Recreate the background thread and queue on send failure","Investigate why the sqlezWorker thread exited (panic in a write callback)","Return an error to callers instead of panicking"],"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-14T05:17:10.506Z"}