zed-industries/zed · error

Queues are inserted when build is called. This should always

Error message

Queues are inserted when build is called. This should always succeed

What it means

The thread-safe connection write path asserts its write queue exists in the global QUEUES map; it is inserted when build() is called, so a missing entry means write() was invoked on a connection whose queue was never registered or was invalidated without recreation.

Source

Thrown at crates/sqlez/src/thread_safe_connection.rs:177

    fn open_file(uri: &str) -> Connection {
        Connection::open_file(uri)
    }

    /// Opens a shared memory connection using the file path as the identifier. This is internal
    /// and only called from the deref function.
    fn open_shared_memory(uri: &str) -> Connection {
        Connection::open_memory(Some(uri))
    }

    pub fn write<T: 'static + Send + Sync>(
        &self,
        callback: impl 'static + Send + FnOnce(&Connection) -> T,
    ) -> impl Future<Output = T> {
        // Check and invalidate queue and maybe recreate queue
        let queues = QUEUES.read();
        let write_channel = queues
            .get(&self.uri)
            .expect("Queues are inserted when build is called. This should always succeed");

        // Create a one shot channel for the result of the queued write
        // so we can await on the result
        let (sender, receiver) = oneshot::channel();

        let thread_safe_connection = (*self).clone();
        write_channel(Box::new(move || {
            let connection = thread_safe_connection.deref();
            let result = connection.with_write(|connection| callback(connection));
            sender.send(result).ok();
        }));
        receiver.map(|response| response.expect("Write queue unexpectedly closed"))
    }

    pub(crate) fn create_connection(
        persistent: bool,
        uri: &str,
        connection_initialize_query: Option<&'static str>,

View on GitHub (pinned to f4178619ac)

Solutions

  1. Ensure build() always runs before any write on the connection
  2. Recreate the queue after invalidation instead of assuming presence
  3. Use queues.get().ok_or() and surface a proper error
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/sqlez/src/thread_safe_connection.rs:177 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/0d005df0ea14f6d9. Report an issue: GitHub.