-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should we expose reserved clients? #1216
Comments
@n8schloss did you have specific requirements around reserved clients? How does the above sound? |
Couple thoughts:
|
As soon as it can be messaged/navigated. I'm sure it's more nuanced than that though.
Right now, It could reject if it's given a valid reserved client ID that doesn't become a client, but I think that'd be a race condition. If you wait long enough, that ID will no longer be reserved, so it'll resolve undefined. |
In previous discussions reserved became non-reserved at execution ready time. This is at least a spec'd point in time for each global (although implementations may vary in reality of course): https://html.spec.whatwg.org/#concept-environment-execution-ready-flag
So, delayed resolution until we detect the global for I guess that's feasible. |
Are there cases where we don't even create a global? We definitely know when a response can't form a client, or when it's redirected cross-origin, so we can resolve null then. |
But, the service worker gets the I think per the current spec we are always supposed to have a reserved Client even if the browser is "optimizing" by delaying the creation of the global. For example, right now firefox avoids creating the initial about:blank window global when it can, but I still pre-allocate a reserved Client ID for it. (Edit: although that is not reserved since the about:blank should be execution ready.) |
I think we're agreeing. |
From memory, I think we wanted reserved clients so we had somewhere to describe the details of the window the new page would appear in, in advance. However, we have that via I don't think we all understood how |
F2F: No objections to this in general. Avoids all the issues around reserved clients that @wanderview identified. Action: Spec this. Close related issues in #1206. |
Reserved client won't be exposed. Spec'ing |
To reflect the decision to not expose reserved clients (#1216) and to spec .resultingClientId and .targetClientId in Nightly only, this: * Removes - Client.reserved and its associated reserved state (V1, Nightly) - ClientQueryOptions.includeReserved (V1, Nightly) - FetchEvent.reservedClientId (V1) - FetchEvent.targetClientId (V1) - FetchEventInit.reservedClientId (V1) - FetchEventInit.targetClientId (V1) * Changes - FetchEvent.reservedClientId to FetchEvent.resultingClientId (Nightly) - FetchEventInit.reservedClientId to FetchEventInit.resultingClientId (Nightly) - Handle Fetch to set FetchEvent.clientId for a navigation request to the empty string (V1) * Corrects - matchedClients with clientObjects in Clients.matchAll() (V1, Nightly) Related issue: #1245. This also cleans up sort condition steps in Clients.matchAll() that fixes #1080 (V1, Nightly) (Changes for the Clients interface's methods will be addressed as separate PRs.)
As per the decision in w3c/ServiceWorker#1216. Related spec PR: w3c/ServiceWorker#1259.
To reflect the decision to not expose reserved clients (#1216) and to spec .resultingClientId and .targetClientId in Nightly only, this: * Removes - Client.reserved and its associated reserved state (V1, Nightly) - ClientQueryOptions.includeReserved (V1, Nightly) - FetchEvent.reservedClientId (V1) - FetchEvent.targetClientId (V1) - FetchEventInit.reservedClientId (V1) - FetchEventInit.targetClientId (V1) * Changes - FetchEvent.reservedClientId to FetchEvent.resultingClientId (Nightly) - FetchEventInit.reservedClientId to FetchEventInit.resultingClientId (Nightly) - Handle Fetch to set FetchEvent.clientId for a navigation request to the empty string (V1) * Corrects - matchedClients with clientObjects in Clients.matchAll() (V1, Nightly) Related issue: #1245. This also cleans up sort condition steps in Clients.matchAll() that fixes #1080 (V1, Nightly) (Changes for the Clients interface's methods will be addressed as separate PRs.)
To reflect the decision that we don't expose reserved clients (#1216), this change introduces the client's discarded flag, and uses that flag and the execution ready flag to resolve the promise when the client reaches one of those states instead of capturing and exposing the reserved client. Follow-up to 07e9487 (#1259).
Based on what we discussed in #1091:
You'll get a real client in the weird
about:blank
case, otherwise you'll get a reserved client, where.navigate
fails.It's got me wondering if we shouldn't expose reserved clients at all. Instead,
clients.get(resultingClientId)
should wait until the client exists before resolving with a real client (or resolve undefined if the client will never exist).This way we don't have to deal with queuing
postMessage
, and developers don't have to worry about what reserved clients can & can't do.The downside is you could create a deadlock:
This would deadlock for all navigations, except in the case of the
about:blank
edge case. Given that deadlock here is the common scenario, it doesn't bother me too much. It'd be easy spotted during development.The text was updated successfully, but these errors were encountered: