Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection closes without recovery #22

Open
erquhart opened this issue Jan 15, 2025 · 0 comments · May be fixed by #26
Open

Connection closes without recovery #22

erquhart opened this issue Jan 15, 2025 · 0 comments · May be fixed by #26

Comments

@erquhart
Copy link

erquhart commented Jan 15, 2025

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

  1. Once token authenticate succeeds, a refetch is scheduled for just before the new token expires.
  2. Around the time of the scheduled refetch, the user initiates a query or mutation with the near-expired token.
  3. The server finds the token to be expired and returns an auth error.
  4. Reauthentication is attempted, which stops the websocket connection and fetches a new token.
  5. In a race condition, the scheduled refetch runs at this point, rendering the still-running reauthentication attempt outdated.
  6. The reauthentication attempt returns early due to being outdated, never restarts the connection (which would happen here).
  7. The scheduled refetch resolves, but no authentication call can be made as the connection is stopped.
  8. 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant