navigator.serviceWorker.register resolves even if installation fails
Reported by
guiller...@netnotion.com,
Jun 27 2016
|
||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36 Steps to reproduce the problem: 1. In a Service Worker use cache.addAll to add a non-existing asset URL (404). 2. Try to install the service worker, in Developers tools it will show as failed 3. navigator.serviceWorker.register will not catch the problem, and will execute the then() Promise. What is the expected behavior? Should catch the SW registration, since it failed. What went wrong? It did not catch it, even though the SW registration failed. Did this work before? N/A Chrome version: 51.0.2704.103 Channel: n/a OS Version: OS X 10.11.1 Flash Version: Shockwave Flash 22.0 r0 https://gist.github.com/helloguille/466e61a9b5ea8d6632542a4b41ce7192
,
Jun 28 2016
I think this is working as intended. The spec defines that a promise returned by register() should be resolved before an install event is fired.
In the Install algorithm on the spec:
7. Invoke Resolve Job Promise with job and the ServiceWorkerRegistration object which represents registration.
11. Queue a task task to run the following substeps:
1. Create a trusted event e that uses the InstallEvent interface, with the event type install, which does not bubble, is not cancelable, and has no default action.
https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#installation-algorithm
,
Jun 28 2016
In my understanding, installation is considered separately from registration, and a promise returned by register() indicates a result of registration, not installation. Please file an issue on spec's bug tracker if you have a question about this behavior: https://github.com/slightlyoff/ServiceWorker
,
Jun 29 2016
Yep, register() resolves once there is an installing worker. It doesn't mean the worker installed yet. You can use ServiceWorker.onstatechange to see if it reaches 'installed' or 'redundant'.
,
Jun 29 2016
Hi! Sorry for the false alarm, I should have a better look of the spec.
,
Jun 29 2016
No problem! :) |
||
►
Sign in to add a comment |
||
Comment 1 by eroman@chromium.org
, Jun 28 2016