fix(service-worker): give the page activation deadline slack past the drain window (Q-6.6-10b)

The page and the worker both used clientDrainMs (30s). A tab that drained at
29.999s let the worker call skipWaiting() and commit after the page had
already resolved CLIENT_DRAIN_TIMEOUT, so the requesting tab never reloaded.
The page now waits clientDrainMs + activationReplySlackMs (new additive
SERVICE_WORKER_BOUNDS field, 5s).

Verified: RED first with the real page/worker seam (last drain at 29.999s,
skipWaiting 50ms): page resolved CLIENT_DRAIN_TIMEOUT; green after.
Gates: check:architecture, types app/test/service-worker, lint, test:unit
(only pre-existing removal-fixture failure), test:component.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-09-24 13:37:56 +09:00
co-authored by Claude Opus 5.5
parent 3b1830c264
commit a3b9381408
3 changed files with 45 additions and 1 deletions
@@ -381,7 +381,12 @@ export function createServiceWorkerPageController(
}
const nonce = nonces.issue();
const deadline = now() + SERVICE_WORKER_BOUNDS.clientDrainMs;
// Q-6.6-10b. With equal deadlines a tab draining at 29s left this page at
// TIMEOUT while the worker still committed skipWaiting().
const deadline =
now() +
SERVICE_WORKER_BOUNDS.clientDrainMs +
SERVICE_WORKER_BOUNDS.activationReplySlackMs;
const accepted = await new Promise<ServiceWorkerActivationOutcome>(
(resolve) => {
const container = dependencies.container;
+5
View File
@@ -17,6 +17,11 @@ export const SERVICE_WORKER_BOUNDS = Object.freeze({
fetchConcurrency: 4,
installDeadlineMs: 60_000,
clientDrainMs: 30_000,
/**
* Q-6.6-10b. The page waits the worker's whole drain window plus this, so
* a drain that ends just in time is followed by skipWaiting() and the reply.
*/
activationReplySlackMs: 5_000,
updateCheckIntervalMs: 6 * 60 * 60 * 1_000,
retainedPreviousCaches: 1,
reloadGuardBytes: 512,