Skip to content

Commit 9e9fe27

Browse files
authored
Editorial: queue a task to reject promise in InstallEvent.addRoutes (#1839)
The rejection path in the [[service worker queue]] block was resolving/rejecting a JS promise directly from a parallel queue, which violates the same pattern that #1740 flags. Wrap it in a Queue a task on the service worker event loop, and abort further steps so we don't also set the rules and resolve the same promise afterwards. Refs: #1740
1 parent 1bcbd24 commit 9e9fe27

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

index.bs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,14 +1642,17 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
16421642

16431643
Note: this step is for making |lifetimePromise| always fullfilled to avoid the install event failure.
16441644

1645+
1. Let |serviceWorkerEventLoop| be the [=current global object=]'s [=event loop=].
16451646
1. [=queue/Enqueue=] the following steps to [=[[service worker queue]]=]:
16461647
1. Let |allRules| be a copy of |serviceWorker|'s [=list of router rules=].
16471648
1. For each |rule| of |rules|:
16481649
1. Append |rule| to |allRules|.
16491650

1650-
1. If running the [=Check Router Registration Limit=] with |allRules| returns false, reject |promise| with a {{TypeError}}.
1651+
1. If running the [=Check Router Registration Limit=] with |allRules| returns false, then:
1652+
1. [=Queue a task=] to run the following steps on |serviceWorkerEventLoop| using the [=DOM manipulation task source=]:
1653+
1. Reject |promise| with a {{TypeError}}.
1654+
1. Abort these steps.
16511655
1. Set |serviceWorker|'s [=service worker/list of router rules=] to |allRules|.
1652-
1. Let |serviceWorkerEventLoop| be the [=current global object=]'s [=event loop=].
16531656
1. [=Queue a task=] to run the following steps on |serviceWorkerEventLoop| using the [=DOM manipulation task source=]:
16541657
1. Resolve |promise| with undefined.
16551658
1. Return |promise|.

0 commit comments

Comments
 (0)