Re: [w3c/ServiceWorker] Declarative routing (#1373)

Sorry for being late to the discussion.
When I wrote the explainer, I did not consider 3rd party SW providers to use the API.  However, considering the use case, it makes more sense to allow the routes updated multiple times.

For the naming of the API,
I remember that we called it `register` instead of `add` to clarify it is a write once operation.  Note that Jake's original proposal called it `add` and allowed to call it multiple times.  If we allow it to be called multiple times, I prefer to rename it `add` or `append` instead, which sounds more like the rules can grow.

By the way, I have concerns on calling the API multiple times,
1) Is the order of the API call guaranteed?  The current `registerRouter` is an asynchronous API.  When the multiple rule has been installed via the API, how should the order of the routes be?  I am not so much familiar with JavaScript, but if JavaScript may not wait for the previous API call, then the order of rules may flip?
2) I also have the same concern as @sisidovski.  If somebody sets a rule that has an intersection with other rules, it may interfere unexpectedly.  Moreover, if somebody sets a rule like:
  ```
  {
    condition: {}, // i.e. matches everything.
    source: "fetch-handler"
  }
  ```
  all rule updates after the rule would be just ignored.  I guess it would be fine to be WAI if the order of rules is guaranteed.



> Calling registerRoutes outside the install event

It is intended to make the rule updated only inside the install event.
We were concerned about the difficulty of understanding rule applications to inflight requests. 

> Would it be possible to make the origin trial a 3rd party origin trial?

FYI, https://bugs.chromium.org/p/chromium/issues/detail?id=1471005

>  is there a benefit to registerRoutes vs calling registerRoute as many times as needed?

Current API accepts both sequence of routes and a route.  I suppose you suggest only accepting a route.
I feel it is fine to allow both ways of writing a rule. i.e. sequence of rules and a rule.  For those who want to understand an error, they can write a rule one by one.  For those who want to write a rule at once, it is also allowed.

Will you elaborate more on why you want to prohibit accepting a sequence of rules?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1373#issuecomment-1676767397
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/ServiceWorker/issues/1373/1676767397@github.com>

Received on Monday, 14 August 2023 06:45:32 UTC