Merged
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
|
Contributor
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
|
02220b1 to
ef179a4
Compare
adhami3310
approved these changes
Nov 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.