angular-docs-cn/packages/service-worker/worker/test
George Kalpakas 9498da1038 fix(service-worker): correctly determine client ID on navigation requests (#42607)
The ServiceWorker assigns an app-version to a each client to ensure that
all subsequent requests for a client are served using the same
app-version. The assignment is done based on the client ID.

Previously, the ServiceWorker would only try to read the client's ID off
of the `FetchEvent`'s `clientId` property. However, for navigation
requests the new client's ID will be set on [resultingClientId][1],
while `clientId` will either be empty or hold the ID of the client where
the request initiated from. See also related discussions in
w3c/ServiceWorker#870 and w3c/ServiceWorker#1266.

In theory, this could lead to the navigation request (i.e. `index.html`)
being served from a different app-version than the subsequent
sub-resource requests (i.e. assets). In practice, the likelihood of this
happening is probably very low though, since it would require the latest
app-version to be updated between the initial navigation request and the
first sub-resource request, which should happen very shortly after the
navigation request.

This commit ensures that the correct client ID is determined even for
navigation requests by also taking the `resultingClientId` property into
account.

[1]: https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/resultingClientId

PR Close #42607
2021-06-22 16:28:24 +00:00
..
BUILD.bazel test: setup circular dependency tests for all entry points (#34774) 2020-01-23 11:36:40 -08:00
data_spec.ts feat(service-worker): add the option to prefer network for navigation requests (#38565) 2020-09-22 09:29:20 -07:00
happy_spec.ts fix(service-worker): correctly determine client ID on navigation requests (#42607) 2021-06-22 16:28:24 +00:00
idle_spec.ts fix(service-worker): allow checking for updates when constantly polling the server (#40234) 2021-01-11 10:42:50 -08:00
prefetch_spec.ts fix(service-worker): allow checking for updates when constantly polling the server (#40234) 2021-01-11 10:42:50 -08:00