Closed
Description
Bug
The websocket connection can quietly drop without recovery. This happens often when a native app is brought from background after token has expired, but can happen outside of this context as well.
Walkthrough
- Once token authenticate succeeds, a refetch is scheduled for just before the new token expires.
- Around the time of the scheduled refetch, the user initiates a query or mutation with the near-expired token.
- The server finds the token to be expired and returns an auth error.
- Reauthentication is attempted, which stops the websocket connection and fetches a new token.
- In a race condition, the scheduled refetch runs at this point, rendering the still-running reauthentication attempt outdated.
- The reauthentication attempt returns early due to being outdated, never restarts the connection (which would happen here).
- The scheduled refetch resolves, but no authentication call can be made as the connection is stopped.
- The scheduled refetch ends with a socket resume attempt, which does not work on stopped connections.
The socket remains closed. Authentication state is unchanged, client appears authenticated to the user.
Root cause
tryToReauthenticate()
no longer restarts the socket as of this commit: 27fe643#diff-d191fc16ddb7007da8373029e3fc1610dfa34b8d95aa26652313bd672ec52699L227. A tryToReauthenticate()
that is followed by a refetchToken()
This change was clearly purposeful, maybe a team member can shed some light?
Metadata
Metadata
Assignees
Labels
No labels