Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ready promise doesn't work right when controlling registration is resurrected #1198

Open
wanderview opened this issue Sep 21, 2017 · 4 comments

Comments

@wanderview
Copy link
Member

wanderview commented Sep 21, 2017

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.

@jakearchibald
Copy link
Contributor

Agreed. Good catch!

@jakearchibald
Copy link
Contributor

I love a good reduced test.

@wanderview
Copy link
Member Author

Ok, I'll fix in firefox here:

https://bugzilla.mozilla.org/show_bug.cgi?id=1402085

I have a WPT test there we'll upstream.

@wanderview
Copy link
Member Author

Ok, fix should be in FF58. The WPT test will upstream when we next sync with upstream web-platform-tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@jakearchibald @wanderview and others