{"record":{"id":"7983956c3dc499e2","repo":"clockworklabs/SpacetimeDB","slug":"unexpected-error-from-row-iter-bsatn-advance","errorCode":null,"errorMessage":"unexpected error from `_row_iter_bsatn_advance`: {e}","messagePattern":"unexpected error from `_row_iter_bsatn_advance`: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bindings-sys/src/lib.rs","lineNumber":1524,"sourceCode":"    pub fn read(&mut self, buf: &mut Vec<u8>) -> usize {\n        loop {\n            let buf_ptr = buf.spare_capacity_mut();\n            let mut buf_len = buf_ptr.len();\n            let ret = unsafe { raw::row_iter_bsatn_advance(self.raw, buf_ptr.as_mut_ptr().cast(), &mut buf_len) };\n            if let -1 | 0 = ret {\n                // SAFETY: `_row_iter_bsatn_advance` just wrote `buf_len` bytes into the end of `buf`.\n                unsafe { buf.set_len(buf.len() + buf_len) };\n            }\n\n            const TOO_SMALL: i16 = errno::BUFFER_TOO_SMALL.get() as i16;\n            match ret {\n                -1 => {\n                    self.raw = raw::RowIter::INVALID;\n                    return buf_len;\n                }\n                0 => return buf_len,\n                TOO_SMALL => buf.reserve(buf_len),\n                e => panic!(\"unexpected error from `_row_iter_bsatn_advance`: {e}\"),\n            }\n        }\n    }\n\n    /// Returns whether the iterator is exhausted or not.\n    pub fn is_exhausted(&self) -> bool {\n        self.raw == raw::RowIter::INVALID\n    }\n}\n\nimpl Drop for RowIter {\n    fn drop(&mut self) {\n        // Avoid this syscall when `_row_iter_bsatn_advance` above\n        // notifies us that the iterator is exhausted.\n        if self.is_exhausted() {\n            return;\n        }\n        unsafe {","sourceCodeStart":1506,"sourceCodeEnd":1542,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/bindings-sys/src/lib.rs#L1506-L1542","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the server version (spacetime server ping / spacetimedb --version) and align the spacetimedb crate version in Cargo.toml with it.","Clean rebuild and republish: cargo clean && cargo build --release && spacetime publish.","If versions match and it reproduces, file an issue with the errno value printed in the panic."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin the spacetimedb crate version in Cargo.toml to the version of the spacetimedb server you deploy to.","Avoid writing to a table while iterating it; finish the iteration before mutating.","Do a clean rebuild when switching toolchain versions."],"tags":["rust","wasm","abi","row-iterator","version-mismatch"],"backgroundTag":"host-abi-version-mismatch","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}