Content-Length: 332071 | pFad | https://github.com/angular/angular/pull/58131

9D fix(service-worker): assign initializing client's app version, when a… by rozpuszczalny · Pull Request #58131 · angular/angular · GitHub
Skip to content
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

fix(service-worker): assign initializing client's app version, when a… #58131

Conversation

rozpuszczalny
Copy link
Contributor

@rozpuszczalny rozpuszczalny commented Oct 9, 2024

… request is for worker script

When a new version of app is available in a service worker, and a client with old version exists, web workers initialized from a client with old version will now be properly assigned with the same version.

Before this change, a web worker was assigned with the newest version.

Fixes #57971

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #57971

What is the new behavior?

When a web worker script request is made to a service worker, it gets assigned the same version as the tab that created it.

Does this PR introduce a breaking change?

No, unless someone was relying on a faulty behavior

  • Yes
  • No

Other information

@pullapprove pullapprove bot requested a review from alxhub October 9, 2024 08:12
@angular-robot angular-robot bot added the area: service-worker Issues related to the @angular/service-worker package label Oct 9, 2024
@ngbot ngbot bot added this to the Backlog milestone Oct 9, 2024
} else if (this.clientVersionMap.get(event.resultingClientId)! !== hash) {
throw new Error(
`Version mismatch between worker client ${event.resultingClientId} and requesting client ${clientId}`,
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we should throw an error, or fallback to network via return null;

} else if (this.clientVersionMap.get(event.resultingClientId)! !== this.latestHash) {
throw new Error(
`Version mismatch between worker client ${event.resultingClientId} and requesting client ${clientId}`,
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we should throw an error, or fallback to network via return null;

@rozpuszczalny rozpuszczalny force-pushed the bugfix/57971-web-worker-version-mismatch branch from 35c5421 to 00f9e46 Compare October 25, 2024 06:35
@rozpuszczalny rozpuszczalny force-pushed the bugfix/57971-web-worker-version-mismatch branch from 00f9e46 to 7a7acb7 Compare November 5, 2024 12:15
@rozpuszczalny rozpuszczalny force-pushed the bugfix/57971-web-worker-version-mismatch branch from 7a7acb7 to 84d11f7 Compare November 15, 2024 06:26
@rozpuszczalny rozpuszczalny force-pushed the bugfix/57971-web-worker-version-mismatch branch from 84d11f7 to 5d1e997 Compare December 2, 2024 10:00
Copy link
Contributor

@thePunderWoman thePunderWoman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I think the error is fine. If it's too disruptive, we can change it later.

@thePunderWoman thePunderWoman removed the request for review from alxhub April 2, 2025 13:45
@thePunderWoman thePunderWoman added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Apr 2, 2025
… request is for worker script

When a new version of app is available in a service worker, and a client with old version exists, web workers initialized from a client with old version will now be properly assigned with the same version.

Before this change, a web worker was assigned with the newest version.

Fixes angular#57971
@thePunderWoman thePunderWoman force-pushed the bugfix/57971-web-worker-version-mismatch branch from 5d1e997 to d9b0ad3 Compare April 2, 2025 14:10
thePunderWoman pushed a commit that referenced this pull request Apr 2, 2025
… request is for worker script (#58131)

When a new version of app is available in a service worker, and a client with old version exists, web workers initialized from a client with old version will now be properly assigned with the same version.

Before this change, a web worker was assigned with the newest version.

Fixes #57971

PR Close #58131
@thePunderWoman
Copy link
Contributor

This PR was merged into the repository by commit 4546d4f.

The changes were merged into the following branches: main, 19.2.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker area: service-worker Issues related to the @angular/service-worker package target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spawning Web Worker from previous AppVersion results in network fallback
2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/angular/angular/pull/58131

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy