fix(deploy): recover maintenance page on tab refocus & bfcache restore#167
Merged
Conversation
The maintenance page only re-checked /api/healthz via a 5s setInterval and a 20s <meta refresh>. Both are timers, which browsers throttle or suspend in backgrounded tabs and asleep devices. A tab parked on the page during a deploy window could stay stranded on "Brewing a new version" indefinitely after origin recovered. Also poll healthz on visibilitychange (tab refocused) and pageshow (back/forward cache restore) so the live app returns the instant the user looks at the tab, not whenever a throttled timer happens to fire.
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.
Why
Prod-incident report: user stranded on the "Brewing a new version" maintenance page while the origin was fully healthy (verified
/and/api/healthz→ 200 end-to-end through CF→tunnel→nginx→sa-web;cf-cache-status: DYNAMIC, no stale edge copy, no service worker). The page was a stale tab, not a live outage.Root cause
docker/maintenance.htmlonly re-checked/api/healthzvia a 5ssetIntervaland a 20s<meta refresh>. Both are timers — browsers throttle/suspend timers in backgrounded tabs and asleep devices (mobile Safari especially). A tab parked on the page during a deploy window can sit on "Brewing…" indefinitely after origin recovers, because the auto-reload timer never fires.Fix
Also poll healthz on:
visibilitychange(tab brought back to foreground)pageshow(restored from back/forward cache)So the live app returns the instant the user looks at the tab, instead of waiting on a throttled timer. Dependency-free, no behavior change to the happy path;
<meta refresh>remains the no-JS fallback.Test
Static HTML page; no automated test harness for it. Manual: load page, background the tab, bring it back → fires an immediate healthz check.