You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(sw): reload on a controller change only when the build really changed
The previous commit reloaded on any controller change, and three E2E shards
said no. A controller changing is routine: the vendored editor registers a
worker of its own into this scope, ours is re-installed and left waiting on
ordinary loads, and the browser activates it by itself at the next navigation
-- same build, same caches, nothing behind it. Measured at 80ms into a plain
reload of a fresh profile, which is why sw-vendor-cache-first died with
"Execution context was destroyed" in the middle of its probe.
So the condition is two things, and both are load-bearing:
- the new controller is a build this browser has not been running, judged
the way healStaleController judges it -- by the runtime cache, named after
the vendor tree's content. The cache names are snapshotted at boot: read
them when the swap happens and the incoming worker has already created its
own, and asking the outgoing worker instead is asking something a swap may
already have terminated;
- and there are no unsaved edits.
Not "is a document open", which is what left a torn page unrepaired, and not
"did this tab ask for the swap", which misses the cases that actually happen.
Reverse-verified in both directions, locally, which the earlier attempts could
not manage: pinning isNewBuild false turns sw-silent-update red, pinning it
true turns sw-vendor-cache-first red. With the real value, sw-silent-update,
sw-vendor-cache-first, sw-warm, autosave-recovery and font-cache pass -- eight
cases.
Tried and dropped: having sw.js skip its install-time takeover when a core
cache under this build's name already exists, so that a same-build re-install
stops swapping the controller mid-load. Its unit case reverse-verified, but
the local suite is green with and without it, and it has a real cost -- a
rollback to a build this browser has run would no longer be delivered, which
is the font revert's own scenario. Unproven benefit, delicate path, out.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
0 commit comments