fix(app): reconnect quickly after phone sleep - #43
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
ftw-webapp | 617a2f4 | Commit Preview URL Branch Preview URL |
Aug 11 2026, 12:12 PM |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f7103e5192
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| pageShown(): void { | ||
| if (!this.documentVisible || this.#resumeWaiting) return |
There was a problem hiding this comment.
Refresh visibility before handling pageshow
When a page was previously hidden and is restored without a visibilitychange event—the exact fallback this method is intended to provide—documentVisible remains false, so this guard discards pageshow and never starts the reconnect watchdog. Read the current document.visibilityState here, or have the pageshow handler synchronize visibility before calling this method, so a restored stale socket is actually replaced.
Useful? React with 👍 / 👎.
What
Why
A real app wake took 20–40 seconds before fresh data appeared. The source path could wait for a 12-second Noise deadline and then 3/6/12-second retry windows while a browser still reported a dead socket as open.
The new foreground path gives a healthy stream one normal telemetry beat to answer. If it stays quiet, the app replaces the carrier instead of waiting for those stale timers.
Evidence
Before: the old retry chain allowed waits in the reported 20–40 second range.
After, deterministic tests assert:
No phone trace is claimed here because Chrome DevTools remote tracing was unavailable in this environment.
Verification
npm run verifygit diff --checkCloudflare branch builds now use
wrangler versions upload; onlymainuseswrangler deploy.