https://github.com/angular/angular
Revision 9498da1038ffa854effa672fac3a898039853375 authored by George Kalpakas on 22 June 2021, 13:09:39 UTC, committed by Dylan Hunn on 22 June 2021, 16:28:24 UTC
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
1 parent 81a19e4
History
Tip revision: 9498da1038ffa854effa672fac3a898039853375 authored by George Kalpakas on 22 June 2021, 13:09:39 UTC
fix(service-worker): correctly determine client ID on navigation requests (#42607)
Tip revision: 9498da1
File Mode Size
.circleci
.devcontainer
.github
.husky
.ng-dev
.vscode
.yarn
aio
dev-infra
docs
goldens
integration
modules
packages
scripts
third_party
tools
.bazelignore -rw-r--r-- 4.2 KB
.bazelrc -rw-r--r-- 6.4 KB
.bazelversion -rw-r--r-- 213 bytes
.clang-format -rw-r--r-- 73 bytes
.editorconfig -rw-r--r-- 245 bytes
.gitattributes -rw-r--r-- 314 bytes
.gitignore -rw-r--r-- 843 bytes
.gitmessage -rw-r--r-- 7.2 KB
.mailmap -rw-r--r-- 51 bytes
.npmrc -rw-r--r-- 21 bytes
.nvmrc -rw-r--r-- 8 bytes
.prettierrc -rw-r--r-- 157 bytes
.pullapprove.yml -rw-r--r-- 48.0 KB
.yarnrc -rw-r--r-- 130 bytes
BUILD.bazel -rw-r--r-- 2.0 KB
CHANGELOG.md -rw-r--r-- 890.3 KB
CODE_OF_CONDUCT.md -rw-r--r-- 1.1 KB
CONTRIBUTING.md -rw-r--r-- 15.5 KB
LICENSE -rw-r--r-- 1.1 KB
README.md -rw-r--r-- 4.7 KB
WORKSPACE -rw-r--r-- 1.9 KB
browser-providers.conf.js -rw-r--r-- 8.4 KB
gulpfile.js -rw-r--r-- 812 bytes
karma-js.conf.js -rw-r--r-- 8.0 KB
package.json -rw-r--r-- 8.5 KB
renovate.json -rw-r--r-- 2.7 KB
test-events.js -rw-r--r-- 259 bytes
test-main.js -rw-r--r-- 9.4 KB
tslint.json -rw-r--r-- 2.8 KB
yarn.lock -rw-r--r-- 615.5 KB
yarn.lock.readme.md -rw-r--r-- 1.3 KB

README.md

back to top