ready promise doesn't work right when controlling registration is resurrected
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 3.6k
- Forks
- 324
- Avg merge
- 14d 22h
- Merged PRs (30d)
- 1
Description
I was debugging some intermittent failures in our tests when I noticed some strange behavior. Consider:
// start with a service worker
let reg = await navigator.serviceWorker.register(script);
await waitForState(reg.installing, "activated");
// get a controlled document to hold the worker alive
let frame = await withIframe(controlledURL);
// mark the registration as uninstalling, but it won't
// fully uninstall because of the frame
await reg.unregister();
// get the ready promise while in the uninstalling state
let readyPromise = navigator.serviceWorker.ready;
// register the service worker again, resurrecting the currently
// active worker
await navigator.serviceWorker.register(script);
// this will never resolve
await readyPromise;
I also wrote up a glitch to test this:
https://sw-ready-resurrection.glitch.me/
It seems both firefox and chrome have this problem. I think we should resolve the ready promise if we resurrect an uninstalling registration with an active worker and matching scope.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the sequence in the issue and the linked sw-ready-resurrection.glitch.me test: register and activate a service worker, keep a controlled frame alive, unregister, obtain navigator.serviceWorker.ready, then register again. Compare the observed behavior with the service worker registration and ready-promise specification; done means the pending promise resolves after an uninstalling registration is resurrected with an active worker.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100