clockworklabs/SpacetimeDB · error

DbConnectionBuilder can only register a single `on_disconnec

Error message

DbConnectionBuilder can only register a single `on_disconnect` callback.

Instead of registering multiple `on_disconnect` callbacks, register a single callback which does multiple operations.

What it means

Error "DbConnectionBuilder can only register a single `on_disconnect` callback. Instead of registering multiple `on_disconnect` callbacks, register a single callback which does multiple operations." thrown in clockworklabs/SpacetimeDB.

Source

Thrown at sdks/rust/src/db_connection.rs:1185

Instead of registering multiple `on_connect_error` callbacks, register a single callback which does multiple operations."
            );
        }

        self.on_connect_error = Some(Box::new(callback));
        self
    }

    /// Register a callback to run when an established connection is closed.
    ///
    /// The connection is established after the initial connection message is
    /// received from the host. Connection failures before that point invoke
    /// [`Self::on_connect_error`] instead.
    pub fn on_disconnect(
        mut self,
        callback: impl FnOnce(&M::ErrorContext, Option<crate::Error>) + Send + 'static,
    ) -> Self {
        if self.on_disconnect.is_some() {
            panic!(
                "DbConnectionBuilder can only register a single `on_disconnect` callback.

Instead of registering multiple `on_disconnect` callbacks, register a single callback which does multiple operations."
            );
        }
        self.on_disconnect = Some(Box::new(callback));
        self
    }
}

/// Create a [`DbContextImplInner`] wrapped in `Arc<Mutex<...>>`.
fn build_db_ctx_inner<M: SpacetimeModule>(
    #[cfg(not(feature = "browser"))] runtime: Option<Runtime>,

    on_connect_cb: Option<OnConnectCallback<M>>,
    on_connect_error_cb: Option<OnConnectErrorCallback<M>>,
    on_disconnect_cb: Option<OnDisconnectCallback<M>>,
) -> Arc<StdMutex<DbContextImplInner<M>>> {

View on GitHub (pinned to 6dee26c6ef)

When it happens

Trigger: Thrown at sdks/rust/src/db_connection.rs:1185 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of clockworklabs/SpacetimeDB@6dee26c6ef (2026-08-20). Data as JSON: /api/errors/d6ec6411494d489a. Report an issue: GitHub.