Skip to content

fix: resume the Login on a reopened connection - #391

Open
diegolmello wants to merge 6 commits into
mobilefrom
diegolmello/issue-359-relogin-on-reopen
Open

fix: resume the Login on a reopened connection#391
diegolmello wants to merge 6 commits into
mobilefrom
diegolmello/issue-359-relogin-on-reopen

Conversation

@diegolmello

Copy link
Copy Markdown
Member

Proposed changes

A Reopen builds a new connection, and the DDP session the previous Login belonged to is gone with the old one. Nothing logged in again on the new connection, so a reopened Socket carried no authenticated identity — closes #359.

onOpen now resumes the Login when a token is held. It fires after emit("open") and after the open resolves, and it is not awaited: the open path never waits on the Login, and a failure is logged rather than thrown into the websocket callback.

loggedIn was connected && !!resume. The token survives across connections and nothing clears it, so a reopened, anonymous session reported itself logged in. Authentication is now tracked per connection: set when login resolves, cleared when a connection is created, on close, and on logout. The token store is unchanged — it is what makes the resume possible.

Steps to reproduce

  • Connect and log in.
  • Drop the connection so the Socket schedules a Reopen.
  • Once the new connection has handshaken, observe that no login method call goes out, while loggedIn reports true.

Tests

  • a reopened connection with a held token sends one login method call carrying the resume token
  • a reopened connection with no token held sends no login method call
  • the open resolves and open is emitted without waiting on the login response
  • loggedIn is false between the reopen and the login result, and true after it

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.

A reopened connection never logs in again

1 participant