Repository navigation
Probe resumed sockets before waiting for reconnect - #4650
Merged
Merged
Conversation
Detect half-dead connections after a tab resumes and refresh active queries immediately. Cover initially hidden tabs and clear stale resume state when disconnected. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Human comments
What was wrong
When a tab or phone resumes, its realtime socket is often half-dead: still
OPENto the browser, but nothing arrives. The app only noticed after the regular ping cycle and its 5 s pong timeout, then waited out the reconnect backoff, so the first seconds after resume showed stale threads.What changed
Split out of #4532 (commit 631124e, unchanged). Part 1 of 6.
apps/app/src/lib/ws.ts: on becoming visible or coming back online, probe the open socket with a 1.5 s pong timeout and reconnect at once if it does not answer. Tabs that start hidden are tracked too. First reconnect delay drops from 1 s to 250–500 ms (per-client jitter) with a growth factor of 2 up to the same 30 s cap. Anonlineevent in a hidden tab no longer probes.apps/app/src/hooks/realtime-cache-effects.ts,cache-owners/system-cache-effects.ts: after a resume of at least 5 s hidden, refetch the active timeline, thread and sidebar queries right away instead of waiting for the socket verdict.No server, host daemon or wire change. Known trade-off: on a link slower than 1.5 s after wake, the probe reconnects a socket that would have answered.
How you verified
pnpm exec turbo run typecheck lint --filter=@bb/app: pass (0 lint errors).vitest run src/lib/ws.test.ts src/hooks/realtime-cache-effects.test.ts src/hooks/system-cache-effects.test.ts: 104/104 pass, including the new resume probe, initially-hidden and stale-resume-state cases.🤖 Generated with Claude Code