Repository navigation
fix(overlay): keep a page that reconnects in a background tab alive - #457
Conversation
When the link dropped, `leave()` stopped the refresher. On reconnect, `onVisibility()` returned early in its hidden branch because the refresher was gone, so a page still in a background tab never reported itself hidden and never started its hidden heartbeat. The server could then expire it and drop its data. The hidden branch now checks whether the page is already marked hidden instead. A second drop during the `restored` calls (claim-page, redaction) no longer restarts the heartbeat, refresher and collectors while offline: the handler stands down when the link dropped again in between.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
🚀 Deploying Preview to Cloudflare 🚀Preview Deployments by commit
|
|
View your CI Pipeline Execution ↗ for commit c0291d6
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
|
The one red check, "Workers Builds: angular-devtools", isn't from this PR. It's a leftover Cloudflare Worker build that fails on every PR and on main (#431). No fix exists in the repo because it lives in the Cloudflare dashboard. Every other check is green. Generated by Claude Code |
What and why
Found in an audit of the implicit state machines in the overlay's visibility and reconnect handling (
overlay.ts).A page that reconnects while its tab is hidden can expire on the server.
leave()stops the refresher and clears the hidden heartbeat.resendConfig()callsonVisibility(), whose hidden branch started withif (!refresher) return;.hidden: true, never started the 60 s hidden heartbeat, and kept its heartbeat paused.rpc/page-ttl.ts, unlimited while hidden or beating) no longer covered it, so the page and its data could expire while the tab was in the background. The same happened after a bfcachepageshowin a hidden tab.The hidden branch now checks whether the page is already marked hidden (
stillHidden), not whether the refresher runs, and both places that clearstillHiddenreset it.A second drop during reconnect restarted everything while offline.
overlay-link.tsmarks the link online beforerestored, and the overlay'srestoredhandler awaitsclaim-pageand the redaction config. If the link dropped again in between,leave()ran first, and thenresendConfig()still restarted the heartbeat, refresher and collectors offline. Adropscounter now makes the handler stand down; the nextrestoredpicks up.How it was verified
overlay-reconnect-visibility.test.ts:hidden: true, sends hidden beats over 130 s, runs no refresher, and resumes normally when visible.overlay-visibility.test.ts: "keeps a hidden tab marked when it comes back from the back/forward cache still hidden"pnpm test:devtools: 3661 passedpnpm typecheck,pnpm format:check,pnpm commit:checkNo docs change: the behaviour now matches what the docs already describe.
Generated by Claude Code
Summary by CodeRabbit