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

What can I guarantee when the promise returned by register resolves() #1176

Closed
ConradIrwin opened this issue Aug 1, 2017 · 1 comment
Closed

Comments

@ConradIrwin
Copy link

ConradIrwin commented Aug 1, 2017

Hi All, Apologies if this is a silly question. It seems like when I call .register() the promise resolves with a service worker that is active.

Is this guaranteed? Will there by at least any service worker (installing, waiting or active?) on the registration, or can there be none?

I tried tracing through the spec, and it seems (assuming I executed all the job instructions correctly) that this is probably true; but neither https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers or https://developers.google.com/web/fundamentals/instant-and-offline/service-worker/lifecycle say anything about it, so I'm left unsure as to whether this is something I can trust.

Assuming it is true, it might be nice to add something to https://www.w3.org/TR/service-workers-1/#navigator-service-worker-register that makes it clear what I can assume as a caller of the .register() method when the returned promise resolves.

@jakearchibald
Copy link
Contributor

At least one of reg.installing, reg.waiting or reg.active will be a SW object.

I've got a doc sprint coming up, hopefully we can improve MDN as part of that.

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

2 participants