clockworklabs/SpacetimeDB · error

unexpected error from `_row_iter_bsatn_advance`: {e}

Error message

unexpected error from `_row_iter_bsatn_advance`: {e}

What it means

While streaming BSATN-encoded rows, _row_iter_bsatn_advance returned an errno outside the handled set (exhausted, success, BUFFER_TOO_SMALL), which the bindings treat as a logic error. Real HTTP-level or data errors are surfaced differently; this panic means the host and module disagree about the iterator protocol or the handle is corrupted.

Source

Thrown at crates/bindings-sys/src/lib.rs:1524

    pub fn read(&mut self, buf: &mut Vec<u8>) -> usize {
        loop {
            let buf_ptr = buf.spare_capacity_mut();
            let mut buf_len = buf_ptr.len();
            let ret = unsafe { raw::row_iter_bsatn_advance(self.raw, buf_ptr.as_mut_ptr().cast(), &mut buf_len) };
            if let -1 | 0 = ret {
                // SAFETY: `_row_iter_bsatn_advance` just wrote `buf_len` bytes into the end of `buf`.
                unsafe { buf.set_len(buf.len() + buf_len) };
            }

            const TOO_SMALL: i16 = errno::BUFFER_TOO_SMALL.get() as i16;
            match ret {
                -1 => {
                    self.raw = raw::RowIter::INVALID;
                    return buf_len;
                }
                0 => return buf_len,
                TOO_SMALL => buf.reserve(buf_len),
                e => panic!("unexpected error from `_row_iter_bsatn_advance`: {e}"),
            }
        }
    }

    /// Returns whether the iterator is exhausted or not.
    pub fn is_exhausted(&self) -> bool {
        self.raw == raw::RowIter::INVALID
    }
}

impl Drop for RowIter {
    fn drop(&mut self) {
        // Avoid this syscall when `_row_iter_bsatn_advance` above
        // notifies us that the iterator is exhausted.
        if self.is_exhausted() {
            return;
        }
        unsafe {

View on GitHub (pinned to 6dee26c6ef)

Solutions

  1. Check the server version (spacetime server ping / spacetimedb --version) and align the spacetimedb crate version in Cargo.toml with it.
  2. Clean rebuild and republish: cargo clean && cargo build --release && spacetime publish.
  3. If versions match and it reproduces, file an issue with the errno value printed in the panic.
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Module compiled against a spacetimedb bindings crate whose wasm ABI (spacetime_10.x import module) differs from the host server's version; or a RowIter handle reused/invalidated by a conflicting operation such as mutating the table mid-iteration.

Common situations: Deploying a module built with a newer spacetimedb crate to an older self-hosted server (or vice versa) after a toolchain upgrade; iterating a table while a nested call writes to it.

Related errors


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