clockworklabs/SpacetimeDB · error

DbConnectionBuilder can only register a single `on_connect`

Error message

DbConnectionBuilder can only register a single `on_connect` callback.

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

What it means

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

Source

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

    /// multiple `DbConnection`s writing to the same debug file concurrently
    /// may interleave or corrupt the output.
    pub fn with_debug_to_file(mut self, path: impl Into<PathBuf>) -> Self {
        self.additional_logging_path = Some(path.into());
        self
    }

    /// Register a callback to run when the connection is successfully established.
    ///
    /// The connection is established after the initial connection message is
    /// received from the host. The callback will receive three arguments:
    /// - The `DbConnection` which has successfully connected.
    /// - The `Identity` of the successful connection.
    /// - The private access token which can be used to later re-authenticate as the same `Identity`.
    ///   If a token was passed to [`Self::with_token`],
    ///   this will be the same token.
    pub fn on_connect(mut self, callback: impl FnOnce(&M::DbConnection, Identity, &str) + Send + 'static) -> Self {
        if self.on_connect.is_some() {
            panic!(
                "DbConnectionBuilder can only register a single `on_connect` callback.

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

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

    /// Register a callback to run when a connection attempt fails asynchronously.
    ///
    /// This callback is invoked only before the initial connection message is
    /// received from the host. Errors which prevent [`Self::build`] from creating
    /// a connection are returned by [`Self::build`] instead.
    pub fn on_connect_error(mut self, callback: impl FnOnce(&M::ErrorContext, crate::Error) + Send + 'static) -> Self {
        if self.on_connect_error.is_some() {
            panic!(

View on GitHub (pinned to 6dee26c6ef)

When it happens

Trigger: Thrown at sdks/rust/src/db_connection.rs:1146 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/7bca793fe6d1a1ed. Report an issue: GitHub.