fix(shared-internals): clear disconnectingPromise after a failed disconnect - #1098
Open
cpruijsen wants to merge 1 commit into
Open
fix(shared-internals): clear disconnectingPromise after a failed disconnect#1098cpruijsen wants to merge 1 commit into
cpruijsen wants to merge 1 commit into
Conversation
…onnect A rejected performDisconnect() previously left the latch set, so every later disconnect() and connect() failed with the same cached error.
🦋 Changeset detectedLatest commit: a1c2a7f The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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
disconnectInternal()clearsdisconnectingPromisein afinallyso a rejecteddisconnect()no longer leavesConnectionManagerunable to disconnect or connect again. The next call starts a new teardown instead of returning the same cached rejection (#1097). Concurrent in-flightdisconnect()calls still share one promise and the same rejection; only a later call retries.disconnectInternal()is also on theconnect()path, anddisconnectAndClear()disconnects first, so one teardown failure previously blocked reconnect and clear for the life of the instance.try/finallywraps the existingawaitofdisconnectingPromise, matchingControlledExecutor.execute()in this package (clear the in-flight field infinallywhether the task fulfills or rejects). Thetry/finallyform is the patch specified and verified in #1097. An alternative isthis.disconnectingPromise = this.performDisconnect().finally(() => { this.disconnectingPromise = null }).performDisconnect()is unchanged: it still does notdispose()afterdisconnect()throws. Members are already nulled before those awaits, so a retry is a no-op rather than a double-dispose.Test plan
pnpm exec vitest run tests/client/ConnectionManager.test.tsinpackages/shared-internals. New tests fail without thefinally, pass with itpnpm exec vitest runinpackages/shared-internals(59 tests)@powersync/shared-internals(patch)Closes #1097