FCE-3061: SDK reconnect should handle invalid token#514
Draft
MiloszFilimowski wants to merge 7 commits intomainfrom
Draft
FCE-3061: SDK reconnect should handle invalid token#514MiloszFilimowski wants to merge 7 commits intomainfrom
MiloszFilimowski wants to merge 7 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts reconnection behavior in the TS client and React client so that terminal auth/join failures stop an in-progress reconnect cycle, and improves auth-error detection to be case-insensitive/substring-based, with accompanying Vitest coverage.
Changes:
- TS client: stop scheduled reconnects and transition to an error state when an auth/join socket close happens during active reconnection.
- TS client: make
isAuthErrordetection case-insensitive and substring-based; add tests for auth and reconnection behavior. - React client: update
useReconnectionto move UI to"error"onauthError/joinErroronly if already"reconnecting".
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ts-client/src/reconnection.ts | Cancels pending reconnect + sets error state when auth/join close occurs during reconnection. |
| packages/ts-client/src/auth.ts | Updates auth error detection logic to be case-insensitive/substring-based. |
| packages/react-client/src/hooks/internal/useReconnection.ts | Adjusts reconnection UI state transitions for auth/join errors. |
| packages/ts-client/src/tests/auth.test.ts | Adds Vitest coverage for isAuthError matching behavior. |
| packages/ts-client/src/tests/reconnection.test.ts | Adds Vitest coverage for stopping reconnection on auth/join errors mid-reconnect. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
packages/ts-client/src/reconnection.ts: If asocketClosecarries an auth or join error while a reconnect is in progress, clear the scheduled reconnect, set status to error, and stop retrying (still ignores those closes when idle).packages/ts-client/src/auth.ts:isAuthErrormatches case-insensitively and treats known reasons as substrings so server messages likeInvalid tokenare detected reliably.packages/react-client/src/hooks/internal/useReconnection.ts: OnauthError/joinError, move reconnection UI toerroronly when status was alreadyreconnecting.packages/ts-client/src/tests/: Addedauth.test.tsandreconnection.test.ts(Vitest) for the above behavior.Motivation and Context
Reconnection could keep retrying or show the wrong status when the socket closed with auth/join failures, especially if the close reason casing did not match the client’s exact strings. This aligns core and React reconnection state with those terminal failures.
Documentation impact
Types of changes
not work as expected)