- From: Asa Kusuma <notifications@github.com>
- Date: Tue, 25 Feb 2020 18:03:09 -0800
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/ServiceWorker/pull/1506/review/364575816@github.com>
asakusuma commented on this pull request.
Thanks for getting the ball rolling here, @jungkees. And thanks for getting the initial implementation done @SteveBeckerMSFT
> + : Input
+ :: |origin|, an [=/origin=]
+ :: |unclaim|, an optional boolean, false by default
+ : Output
+ :: None
+
+ 1. [=map/For each=] <var ignore=''>scope</var> → |registration| of [=scope to registration map=]:
+ 1. Let |scopeURL| be |registration|'s [=service worker registration/scope url=].
+ 1. If |scopeURL|'s [=/origin=] is |origin|, then:
+ 1. Let |job| be the result of running [=Create Job=] with *unregister*, |scopeURL|, null, null, and null.
+ 1. Set |job|'s [=immediate unregister flag=].
+ 1. Let |jobQueue| be [=scope to job queue map=][|job|'s [=job/scope url=], [=URL serializer|serialized=]].
+ 1. Assert: |jobQueue| is not null.
+ 1. [=While=] |jobQueue| is not empty:
+ 1. Let |job| be the first item in |jobQueue|.
+ 1. Invoke [=Reject Job Promise=] with |job| and "{{AbortError}}" {{DOMException}}.
I'm not very familiar with speccing errors, but is there a way to ensure that the error message makes it clear that the promise was rejected because the service worker was purged?
> + <h3 id="purge-service-worker-registration-algorithm"><dfn export>Purge Service Worker Registrations</dfn></h3>
+
+ : Input
+ :: |origin|, an [=/origin=]
+ :: |unclaim|, an optional boolean, false by default
+ : Output
+ :: None
+
+ 1. [=map/For each=] <var ignore=''>scope</var> → |registration| of [=scope to registration map=]:
+ 1. Let |scopeURL| be |registration|'s [=service worker registration/scope url=].
+ 1. If |scopeURL|'s [=/origin=] is |origin|, then:
+ 1. Let |job| be the result of running [=Create Job=] with *unregister*, |scopeURL|, null, null, and null.
+ 1. Set |job|'s [=immediate unregister flag=].
+ 1. Let |jobQueue| be [=scope to job queue map=][|job|'s [=job/scope url=], [=URL serializer|serialized=]].
+ 1. Assert: |jobQueue| is not null.
+ 1. [=While=] |jobQueue| is not empty:
Should we only purge the job queue if `unclaim` is `true`? It might be unexpected to kill all in-flight jobs without also specifying `unclaim`.
> + 1. Let |scopeURL| be |registration|'s [=service worker registration/scope url=].
+ 1. If |scopeURL|'s [=/origin=] is |origin|, then:
+ 1. Let |job| be the result of running [=Create Job=] with *unregister*, |scopeURL|, null, null, and null.
+ 1. Set |job|'s [=immediate unregister flag=].
+ 1. Let |jobQueue| be [=scope to job queue map=][|job|'s [=job/scope url=], [=URL serializer|serialized=]].
+ 1. Assert: |jobQueue| is not null.
+ 1. [=While=] |jobQueue| is not empty:
+ 1. Let |job| be the first item in |jobQueue|.
+ 1. Invoke [=Reject Job Promise=] with |job| and "{{AbortError}}" {{DOMException}}.
+ 1. [=queue/Dequeue=] from |jobQueue|.
+ 1. Invoke [=Schedule Job=] with |job|.
+ 1. Wait until |job|'s [=job promise=] settles.
+ 1. If |unclaim| is true, then:
+ 1. For each [=/service worker client=] |client| [=using=] |registration|:
+ 1. Assert: |client|'s [=active service worker=] is not null.
+ 1. Invoke [=Handle Service Worker Client Unload=] with |client|.
What's the purpose of calling `Handle Service Worker Client Unload` here? I believe `Handle Service Worker Client Unload` will call `Try Unregister` and `Try Activate`, not sure either of those are necessary since we already did `unregister` and we shouldn't be trying to activate a new service worker.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/pull/1506#pullrequestreview-364575816
Received on Wednesday, 26 February 2020 02:03:21 UTC