Disconnect with intent - #5782
Open
onx2 wants to merge 5 commits into
Open
Conversation
onx2
commented
Aug 23, 2026
| Local(PendingMutation<M>), | ||
| } | ||
|
|
||
| fn disconnect_result( |
Contributor
Author
There was a problem hiding this comment.
Making this a function might be a little overkill 🤷🏻
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.
Description of Changes
Adds a new
DisconnectIntentAPI to the Rust SDK. Consumers can useon_disconnect_with_intentto distinguish client-requested disconnects, lost connections, and SDK errors. The existingon_disconnectAPI remains unchanged for compatibility.Use case
Automatic reconnect should apply only to unexpected disconnects, and application-requested disconnects are distinct. For example, when a game player logs out or switches accounts, the client intentionally calls
disconnect(). If the reconnect system treats that event like a network failure, it may reconnect with the cached credentials, restore subscriptions, and make the player appear online again—or reconnect to the wrong account or database (depending on user's implementation).Exposing whether a disconnect was intentional lets integrations such as
bevy_stdbreconnect after network/server failures while remaining disconnected after explicit application shutdown or logout using internal SDK semantics.API and ABI breaking changes
This is additive and does not break the existing API or ABI, but I think in v3 the
on_disconnectshould be replaced by this version.Expected complexity level and risk
1/5
This adds disconnect intent information without changing existing behavior for current consumers.
Testing
cargo check -p spacetimedb-sdkcargo test -p spacetimedb-sdk --lib