Skip to content

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).

@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
@arturovt arturovt force-pushed the fix/service-worker-concurrent-checkForUpdate branch from 2bcbcd5 to 62d7870 Compare May 22, 2025 16:59
…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).
@arturovt arturovt force-pushed the fix/service-worker-concurrent-checkForUpdate branch from 62d7870 to 88916e1 Compare June 3, 2025 17:34
@atscott atscott added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Jun 3, 2025
@kirjs
Copy link
Contributor

kirjs commented Jun 3, 2025

This PR was merged into the repository by commit 6adf022.

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

kirjs pushed a commit that referenced this pull request Jun 3, 2025
…te checks (#61443)

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).

PR Close #61443
@kirjs kirjs closed this in 6adf022 Jun 3, 2025
@arturovt arturovt deleted the fix/service-worker-concurrent-checkForUpdate branch June 3, 2025 20:37
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

3 participants