Avoid WebSocket coordinator countdown rerenders#2647
Draft
cursor[bot] wants to merge 3 commits into
Draft
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
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.
What Changed
nowMsReact state fromWebSocketConnectionCoordinatorso the reconnect toast countdown no longer re-renders the coordinator every second.useWebSocketConnectionCoordinatorEffects, and refreshed the reconnect toast via an effect event instead of render-driving state.docs/performance/react-scan-websocket-coordinator-before.webmdocs/performance/react-scan-websocket-coordinator-after.webmdocs/performance/react-scan-websocket-coordinator-before.jsondocs/performance/react-scan-websocket-coordinator-after.jsonWhy
React Doctor flagged
WebSocketConnectionSurface.tsxwithrerender-state-only-in-handlers:nowMswas updated for countdown bookkeeping but never rendered by the component. In the reconnect waiting state this caused avoidable coordinator update renders once per second. The toast still updates on the same cadence, but the coordinator no longer needs to re-render for those ticks.React-scan/Profiler capture summary over the same ~5.5s reconnect countdown harness:
UI Changes
No product UI behavior change intended. The committed
.webmfiles are before/after screen recordings with react-scan enabled for the reconnect countdown harness.Checklist
Validation:
bun fmtbun lintbun typecheckbunx --bun react-doctor@latest . --diff main --verbose --json --offline --fail-on noneNote
Avoid 1s interval re-renders in
WebSocketConnectionCoordinatoruseWebSocketConnectionCoordinatorEffectshook in WebSocketConnectionSurface.tsx, removingnowMsstate and its interval-driven updates.syncConnectionToastcallback directly on a timer instead of updating React state, eliminating 1s re-renders on the coordinator component.docs/performance/to document the improvement.Macroscope summarized f9a634d.