Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(service-worker): prevent duplicate fetches during concurrent update checks #61443

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
Loading
from

Conversation

arturovt
Copy link
Contributor

Previously, multiple simultaneous calls to checkForUpdate() could result in redundant fetches and hashing of the update manifest, leading to unnecessary network and CPU usage.

This change introduces a mechanism to track an in-progress update check using a cached promise (ongoingCheckForUpdate). Subsequent calls to checkForUpdate() while a check is in progress will return the same promise instead of triggering a new request.

Once the check completes (successfully or not), the cached promise is cleared, allowing future update checks to proceed normally.

This improves efficiency and prevents overlapping update logic in applications that may invoke checkForUpdate() from multiple sources (e.g. polling, manual triggers).

…te checks

Previously, multiple simultaneous calls to `checkForUpdate()` could result in redundant
fetches and hashing of the update manifest, leading to unnecessary network and CPU usage.

This change introduces a mechanism to track an in-progress update check using a cached
promise (`ongoingCheckForUpdate`). Subsequent calls to `checkForUpdate()` while a check
is in progress will return the same promise instead of triggering a new request.

Once the check completes (successfully or not), the cached promise is cleared,
allowing future update checks to proceed normally.

This improves efficiency and prevents overlapping update logic in applications that
may invoke `checkForUpdate()` from multiple sources (e.g. polling, manual triggers).
@pullapprove pullapprove bot requested a review from atscott May 16, 2025 22:26
@angular-robot angular-robot bot added the area: service-worker Issues related to the @angular/service-worker package label May 16, 2025
@ngbot ngbot bot added this to the Backlog milestone May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: service-worker Issues related to the @angular/service-worker package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.