Repository navigation
Don't block disconnect on pending checkpoint requests - #491
Merged
simolus3 merged 1 commit intoOct 22, 2026
Merged
Conversation
simolus3
approved these changes
Oct 22, 2026
simolus3
left a comment
Contributor
There was a problem hiding this comment.
With the checkpoint request is tied to the current abort signal, I feel comfortable with the sync client being used outside of the mutex.
Thanks for the contribution 👍
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.
Closes #483.
ConnectionManager.requestCheckpoint()heldsyncConnectMutexwhile waiting for the service to respond, andStreamingSyncImplementation.requestCheckpoint()ran the request under anAbortControllerthat nothing aborted. If the service accepted the request but never answered,disconnect(),disconnectAndClear()andclose()waited on the mutex until the service came back.This implements the first suggested fix from the issue:
ConnectionManager.requestCheckpoint()only holdssyncConnectMutexto read the active sync client, and awaits the request after releasing it.StreamingSyncImplementation.requestCheckpoint()ties the request to the abort controller of the active sync iteration. Disconnecting aborts both the wait for the checkpoint seed and thesync/checkpoint-requestcall. The pendingrequestCheckpoint()fails with the existingCheckpointRequestException("sync client is disconnected").The API additions from the issue (an
abortTriggeronrequestCheckpoint()and an abort signal forpostCheckpointRequest) are left for a separate change.Testing
The new test
disconnect aborts pending requestsintest/sync/in_memory_sync_test.dartstalls the mocksync/checkpoint-requesthandler, callsrequestCheckpoint(), and expectsdisconnect()to complete within 5 seconds and the request to fail withdisconnected. It fails onmainwithTimeoutExceptionand passes with this change (JSON and BSON variants).dart test -p vmpasses, except forupload_test.dart, which is flaky onmainas well.dart formatanddart analyze --fatal-infos --fatal-warningsare clean.