Skip to content

Commit f5fafc7

Browse files
Avoid ServiceWorker failure on addRoutes() failure
1 parent 050f195 commit f5fafc7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

docs/index.bs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1612,11 +1612,17 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
16121612
1. For each |rule| of |rules|:
16131613
1. If running the [=Verify Router Condition=] algorithm with |rule|["{{RouterRule/condition}}"] and |serviceWorker| returns false, return [=a promise rejected with=] a {{TypeError}}.
16141614
1. If |rule|["{{RouterRule/source}}"] is "{{RouterSourceEnum/fetch-event}}" and |serviceWorker|'s [=set of event types to handle=] does not [=set/contain=] {{ServiceWorkerGlobalScope/fetch!!event}}, return [=a promise rejected with=] a {{TypeError}}.
1615-
1. Let |promise| be a new [=promise=].
1616-
1. [=ExtendableEvent/Add lifetime promise=] |promise| to |event|.
1615+
1. Let |lifetimePromise| be a new [=promise=].
1616+
1. [=ExtendableEvent/Add lifetime promise=] |lifetimePromise| to |event|.
16171617

16181618
Note: {{InstallEvent/addRoutes(rules)|event.addRoutes(rules)}} extends the lifetime of the event by default as if {{ExtendableEvent/waitUntil()|event.waitUntil(promise)}} is called.
16191619

1620+
1. Let |promise| be a new [=promise=].
1621+
1. [=In parallel=]:
1622+
1. Upon [=upon fulfillment|fulfillment=] or [=upon rejection|rejection=] of |promise|, resolve |lifetimePromise| with undefined.
1623+
1624+
Note: this step is for making |lifetimePromise| always fullfilled to avoid the install event failure.
1625+
16201626
1. Let |serviceWorkerEventLoop| be the [=current global object=]'s [=event loop=].
16211627
1. [=Queue a task=] to run the following steps on |serviceWorkerEventLoop| using the [=DOM manipulation task source=]:
16221628
1. Let |allRules| be a copy of |serviceWorker|'s [=list of router rules=].

0 commit comments

Comments
 (0)