-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Do a full re-hydrate on reconnect #5980
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
Conversation
It turns out that just rehydrating and not also re-running the on_load handlers can leave applications in a bad state; particularly when their background tasks exiting are predicated on the `sid`, that will change on reconnect, but without an on_load, no mechanism is there to restart the tasks.
CodSpeed Performance ReportMerging #5980 will not alter performanceComparing Summary
|
Greptile OverviewGreptile SummaryThis PR reverts the reconnect optimization introduced in PR #5969 to fix issues with background tasks becoming stale after reconnection. Previously, reconnects only sent a hydrate event without running Key Changes:
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Client as Frontend (state.js)
participant Socket as WebSocket
participant Server as Backend
participant Middleware as HydrateMiddleware
Note over Client,Server: Initial Connection
Client->>Socket: connect()
Socket->>Server: WebSocket connection established
Server->>Client: "connect" event
Client->>Client: queue initialEvents()
Client->>Server: hydrate event
Server->>Middleware: preprocess(hydrate)
Middleware->>Middleware: reset client storage
Middleware->>Middleware: set is_hydrated = false
Middleware->>Server: return state delta
Server->>Client: state update + on_load events
Note over Client,Server: Reconnection (After this PR)
Client->>Client: socket.rehydrate = true
Socket--xServer: Disconnected
Client->>Socket: reconnect()
Socket->>Server: WebSocket reconnected
Server->>Client: "connect" event
Client->>Client: Check rehydrate flag = true
Client->>Client: queue ALL initialEvents() (hydrate + on_load)
Client->>Server: hydrate event
Server->>Middleware: preprocess(hydrate)
Middleware->>Middleware: reset client storage
Middleware->>Middleware: set is_hydrated = false
Middleware->>Server: return state delta
Server->>Client: state update + on_load events
Note over Client,Server: Background tasks restart with new sid
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, no comments
02220b1 to
ef179a4
Compare
It turns out that just rehydrating and not also re-running the on_load handlers can leave applications in a bad state; particularly when their background tasks exiting are predicated on the
sid, that will change on reconnect, but without an on_load, no mechanism is there to restart the tasks.