Preserve incoming message delivery integrity and harden reconnect lifecycle - #226
Open
Xare123 wants to merge 9 commits into
Open
Preserve incoming message delivery integrity and harden reconnect lifecycle#226Xare123 wants to merge 9 commits into
Xare123 wants to merge 9 commits into
Conversation
This was referenced Jul 25, 2026
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.
Part 1 of 3. This replaces #225, which mixed too many unrelated themes to review. Split into focused PRs so each can be evaluated on its own.
Series: Part 1 - delivery integrity - Part 2 - lifecycle leaks - Part 3 - reply threads and keyboard
What this fixes
Incoming messages could be delayed, duplicated, or dropped outright. Four distinct causes:
Two queue processors could run at once.
Queue.queue()started a second processor wheneveritems.isEmpty && item is IncomingItem, so a burst of incoming messages could interleave two runners over the same list. A single_runnerActiveguard now owns the drain loop.A failed
prepItemstranded its item. The completer was never completed, so the caller waited forever. Failures now complete the completer with the error and rethrow.Push could be acknowledged after the handler failed. An incoming push was acknowledged even when handling had already thrown, permanently dropping that message. The message is now persisted before acknowledgement, and a failed handler does not acknowledge.
Reconnect had two owners. Socket.IO's automatic reconnect and the manual reconnect path could both be in flight, producing overlapping connection attempts and unnecessary radio wake-ups. Reconnect is now single-owner, guarded by an epoch and a connection generation, so stale attempts are discarded rather than racing.
Also included:
rust/src/native.rs).Validation
flutter analyze: no errors in any file this PR touches. The analyzer reports 31 pre-existing errors inlib/database/html/, vendoredrust_builder/cargokit/, and thetelephony_plusexample; those are unchanged by this PR and present on the base branch.Notes for review
rustpushsubmodule pointer, so it is independent of the dependency chain in Update Anisette v3 provisioning dependency rustpush#33 and Handle current Anisette v3 provisioning states apple-private-apis#6.messages_view.dart,rustpush_service.dart,conversation_tile.dart) and four with Part 3 (chat_messages.dart,database/io/message.dart,messages_service.dart, and thechat_messagestest), but edits different regions of each. Whichever merges first, I will rebase the others.