Closed mfalken closed 7 years ago
Good catch! The spec was changed in favor of developer convenience, this is an unintentional side-effect.
@kitcambridge, would you know what Firefox does here? We haven't implemented this and still reject when calling subscribe()
on a Service Worker that's not activated.
Oof, I don't think we enforce the active worker requirement at all. If the origin has permission, Firefox will happily create the subscription and resolve the promise. https://bugzilla.mozilla.org/show_bug.cgi?id=1244349 is the closest bug for adding that check.
That's unfortunate! Is there any way for you to add telemetry so that we learn whether it's safe to require an active worker in the spec? (And for Firefox to match it.)
Requiring an active worker feels important, otherwise you can subscribe for push at a time that the registration may fail and be discarded.
I'm not bothered if it waits or throws, but we should make sure all service worker APIs do the same thing.
@jakearchibald fixed this in 9349b6616d991aff7396083d6048a04642abee2e
The steps for
subscribe
wait for the installing or waiting version to become active before resolving the promise. This seems to meanoninstall = e => { e.waitUntil(self.registration.subscribe()); }
would cause a deadlock (though the UA may timeout the event and fail the installation). Maybe subscribe() should reject if called without an active worker? I believe Chrome's current implementation does this.