- From: Yoshisato Yanagisawa <notifications@github.com>
- Date: Mon, 27 Jan 2025 02:47:31 -0800
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/ServiceWorker/pull/1744/review/2575095352@github.com>
@yoshisatoyanagisawa commented on this pull request. > - 1. Set |serviceWorker|'s [=service worker/list of router rules=] to |routerRules|. - 1. Return [=a promise resolved with=] undefined. + 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}}. + 1. Let |lifetimePromise| be a new [=promise=]. + 1. [=ExtendableEvent/Add lifetime promise=] |lifetimePromise| to |event|. + + Note: {{InstallEvent/addRoutes(rules)|event.addRoutes(rules)}} extends the lifetime of the event by default as if {{ExtendableEvent/waitUntil()|event.waitUntil(promise)}} is called. + + 1. Let |promise| be a new [=promise=]. + 1. [=In parallel=]: + 1. Upon [=upon fulfillment|fulfillment=] or [=upon rejection|rejection=] of |promise|, resolve |lifetimePromise| with undefined. + + Note: this step is for making |lifetimePromise| always fullfilled to avoid the install event failure. + + 1. Let |serviceWorkerEventLoop| be the [=current global object=]'s [=event loop=]. + 1. [=Queue a task=] to run the following steps on |serviceWorkerEventLoop| using the [=DOM manipulation task source=]: Let me ask on this more. I got confused for this. To allow third-party libraries to set routes, `addRoutes()` can be called multiple times. Also, to avoid ambiguity on the evaluation order, we want to force the rules to be evaluated in the added order. Then, what happens if `addRoutes()` is called multiple times with the suggested process? I am afraid its execution order is not guaranteed. Since it says [=in parallel=], I suppose one procedure can be executed while the other is executed. If multiple `addRoutes()` are called at once, there can be race condition and rules added at the same time may not be lost? That is my intention to make a task to do followings: 1. get the existing rule. 2. add the new rules. 3. write back to |serviceWorker| [=list of router rules=] Or, can we expect the deterministic execution order for [=in parallel=]? -- Reply to this email directly or view it on GitHub: https://github.com/w3c/ServiceWorker/pull/1744#discussion_r1930324511 You are receiving this because you are subscribed to this thread. Message ID: <w3c/ServiceWorker/pull/1744/review/2575095352@github.com>
Received on Monday, 27 January 2025 10:47:35 UTC