Skip to content

fix(browser): restart stopped WebSocket at the end of setConfig - #206

Open
CloudCorpRecords wants to merge 1 commit into
convex:mainfrom
CloudCorpRecords:fix/setauth-reauth-websocket-194
Open

CloudCorpRecords wants to merge 1 commit into
convex:mainfrom
CloudCorpRecords:fix/setauth-reauth-websocket-194

Conversation

@CloudCorpRecords

Copy link
Copy Markdown

If setAuth runs while AuthenticationManager.tryToReauthenticate is waiting
on its forced token fetch (after the server sent an AuthError), the
superseded reauthentication returns early without restarting the socket,
and setConfig's resumeSocket() is a no-op on a stopped socket. The client
then reports isWebSocketConnected: false forever: queries stop updating
and queued mutations never settle.

Call tryRestartSocket() after resumeSocket() at the end of setConfig.
WebSocketManager.tryRestart() only acts when the socket is "stopped", so
this is a no-op outside the race. This mirrors the existing restart at the
end of refetchToken().

Adds a regression test covering both orderings: setConfig while the
reauthentication fetch is pending, and setConfig while stopSocket() is
still closing.

Fixes #194.

If setAuth runs while AuthenticationManager.tryToReauthenticate is waiting
on its forced token fetch (after the server sent an AuthError), the
superseded reauthentication returns early without restarting the socket,
and setConfig's resumeSocket() is a no-op on a stopped socket. The client
then reports isWebSocketConnected: false forever: queries stop updating
and queued mutations never settle.

Call tryRestartSocket() after resumeSocket() at the end of setConfig.
WebSocketManager.tryRestart() only acts when the socket is "stopped", so
this is a no-op outside the race. This mirrors the existing restart at the
end of refetchToken().

Adds a regression test covering both orderings: setConfig while the
reauthentication fetch is pending, and setConfig while stopSocket() is
still closing.

Fixes convex#194.

Signed-off-by: Rene Turcios <95189389+CloudCorpRecords@users.noreply.github.com>
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 this pull request may close these issues.

setAuth during reauthentication after an AuthError leaves the WebSocket stopped permanently

1 participant