fix(dart): use BigInt for int64 serialization on web#92
Open
dillon-0 wants to merge 2 commits intozefchain:mainfrom
Open
fix(dart): use BigInt for int64 serialization on web#92dillon-0 wants to merge 2 commits intozefchain:mainfrom
dillon-0 wants to merge 2 commits intozefchain:mainfrom
Conversation
added 2 commits
March 23, 2026 23:19
ByteData.getInt64() and ByteData.setInt64() throw UnsupportedError on Dart web because JavaScript numbers are 64-bit doubles with no native 64-bit integer support. deserializeInt64() now uses _bytesToBigInt() (the same approach already used by deserializeUint64()). serializeInt64() now uses manual byte-splitting (matching serializeUint64()). This was discovered via rinf (Rust-Flutter bridge) where any signal containing i64 fields silently failed deserialization on web — the signal was sent successfully from Rust but Dart never received it because the bincode deserialization threw an uncaught UnsupportedError.
45ceec2 to
6d87c57
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ByteData.getInt64()andByteData.setInt64()throwUnsupportedErroron Dart web because JavaScript numbers are 64-bit doubles with no native 64-bit integer support.deserializeInt64()now uses_bytesToBigInt()— the same approach already used bydeserializeUint64()serializeInt64()now uses manual byte-splitting — matching the pattern inserializeUint64()Context
This was discovered while using rinf (a Rust-Flutter bridge that uses serde-generate for Dart bindings). Any rinf signal struct containing
i64fields would silently fail deserialization on Dart web —send_signal_to_dart()succeeded on the Rust/WASM side, but the Dart callback threw an uncaughtUnsupportedErrorduring bincode deserialization, so the signal was never delivered.The fix is minimal: both methods already had working cross-platform equivalents in
deserializeUint64/serializeUint64— this PR applies the same pattern to the signed variants.