fix(supabase_flutter): simplify lifecycle reconnection with serial Future chain#1340
Open
brunovsiqueira wants to merge 1 commit intosupabase:mainfrom
Open
fix(supabase_flutter): simplify lifecycle reconnection with serial Future chain#1340brunovsiqueira wants to merge 1 commit intosupabase:mainfrom
brunovsiqueira wants to merge 1 commit intosupabase:mainfrom
Conversation
…uture chain Replace complex lifecycle reconnection logic (_disconnectFuture, _realtimeReconnectOperation, cancel flag) with a serial Future chain and target-state pattern. Operations are serialized via _pendingLifecycleOperation so disconnect and connect never overlap. _targetLifecycleState tracks the most recent lifecycle request, allowing stale operations to be skipped and reconnects to be cancelled if the app goes back to background. Add idempotency guards on both connect (isConnected) and disconnect (isConnected || isConnecting) paths. Add tests for rapid lifecycle flapping and cancellation edge cases.
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
Follow-up to #1321. Replaces the complex lifecycle state tracking (
_disconnectFuture,_realtimeReconnectOperation, cancel flag) with a serial Future chain + target-state pattern, as suggested by @icnahom in the review._pendingLifecycleOperationensures disconnect/connect never overlap_targetLifecycleStatecancels outdated operations (e.g. abort reconnect if app backgrounded again)Test plan
paused → resumed → paused → resumedflapping ends connectedpaused → resumed → pausedbefore connect completes ends disconnectedsupabase_fluttertest suite passesdart formatanddart analyzeclean