Skip to content

refactor(service-worker): avoid unnecessary writes to cache when version fails - #43680

Closed
gkalpak wants to merge 1 commit into
angular:masterfrom
gkalpak:refactor-sw-unnecessary-sync
Closed

gkalpak wants to merge 1 commit into
angular:masterfrom
gkalpak:refactor-sw-unnecessary-sync

Conversation

@gkalpak

@gkalpak gkalpak commented Oct 2, 2021

Copy link
Copy Markdown
Member

When an app version is detected as broken, the SW calls the Driver#versionFailed() method. Previously, this method would in turn call the Driver#sync() method, which writes some metadata about the SW's state to the ngsw:/:db:contol cache. More specifically, Driver#sync() persists info about all known app versions, which one is the latest and also what version each client is assigned to.

However, no relevant info is changed inside Driver#versionFailed(), so the call to Driver#sync() is redundant (since there are no changes that need to be synced with the cache). This is a left-over from before #43518, when Driver#versionFailed() used to update version assignments and thus did require synchronization with the cache.

This commit removes the redundant Driver#sync() call to avoid an unnecessary write to the cache.

@gkalpak gkalpak added action: review The PR is still awaiting reviews from at least one requested reviewer refactoring Issue that involves refactoring or code-cleanup target: patch This PR is targeted for the next patch release area: service-worker Issues related to the @angular/service-worker package labels Oct 2, 2021
@gkalpak
gkalpak requested a review from IgorMinar October 2, 2021 15:32
@ngbot ngbot Bot added this to the Backlog milestone Oct 2, 2021
@google-cla google-cla Bot added the cla: yes label Oct 2, 2021
@mary-poppins

Copy link
Copy Markdown

@gkalpak
gkalpak force-pushed the refactor-sw-unnecessary-sync branch from 1a6b1ee to c3a9ce3 Compare October 5, 2021 17:14
…ion fails

When an app version is detected as broken, the SW calls the
`Driver#versionFailed()` method. Previously, this method would in turn
call the `Driver#sync()` method, which writes some metadata about the
SW's state to the `ngsw:/:db:contol` cache. More specifically,
`Driver#sync()` persists info about all known app versions, which one is
the latest and also what version each client is assigned to.

However, no relevant info is changed inside `Driver#versionFailed()`, so
the call to `Driver#sync()` is redundant (since there are no changes
that need to be synced with the cache). This is a left-over from
before angular#43518, when `Driver#versionFailed()` used to update version
assignments and thus did require synchronization with the cache.

This commit removes the redundant `Driver#sync()` call to avoid an
unnecessary write to the cache.
@mary-poppins

Copy link
Copy Markdown

@IgorMinar IgorMinar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. thanks George!

@gkalpak gkalpak added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Oct 21, 2021
@jessicajaniuk

Copy link
Copy Markdown
Contributor

This PR was merged into the repository by commit c5d0b76.

jessicajaniuk pushed a commit that referenced this pull request Oct 21, 2021
…ion fails (#43680)

When an app version is detected as broken, the SW calls the
`Driver#versionFailed()` method. Previously, this method would in turn
call the `Driver#sync()` method, which writes some metadata about the
SW's state to the `ngsw:/:db:contol` cache. More specifically,
`Driver#sync()` persists info about all known app versions, which one is
the latest and also what version each client is assigned to.

However, no relevant info is changed inside `Driver#versionFailed()`, so
the call to `Driver#sync()` is redundant (since there are no changes
that need to be synced with the cache). This is a left-over from
before #43518, when `Driver#versionFailed()` used to update version
assignments and thus did require synchronization with the cache.

This commit removes the redundant `Driver#sync()` call to avoid an
unnecessary write to the cache.

PR Close #43680
jessicajaniuk pushed a commit that referenced this pull request Oct 21, 2021
…ion fails (#43680)

When an app version is detected as broken, the SW calls the
`Driver#versionFailed()` method. Previously, this method would in turn
call the `Driver#sync()` method, which writes some metadata about the
SW's state to the `ngsw:/:db:contol` cache. More specifically,
`Driver#sync()` persists info about all known app versions, which one is
the latest and also what version each client is assigned to.

However, no relevant info is changed inside `Driver#versionFailed()`, so
the call to `Driver#sync()` is redundant (since there are no changes
that need to be synced with the cache). This is a left-over from
before #43518, when `Driver#versionFailed()` used to update version
assignments and thus did require synchronization with the cache.

This commit removes the redundant `Driver#sync()` call to avoid an
unnecessary write to the cache.

PR Close #43680
@gkalpak
gkalpak deleted the refactor-sw-unnecessary-sync branch October 21, 2021 14:56
@angular-automatic-lock-bot

Copy link
Copy Markdown

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 Nov 21, 2021
Serginho pushed a commit to TuLotero/angular that referenced this pull request Jan 20, 2022
…ion fails (angular#43680)

When an app version is detected as broken, the SW calls the
`Driver#versionFailed()` method. Previously, this method would in turn
call the `Driver#sync()` method, which writes some metadata about the
SW's state to the `ngsw:/:db:contol` cache. More specifically,
`Driver#sync()` persists info about all known app versions, which one is
the latest and also what version each client is assigned to.

However, no relevant info is changed inside `Driver#versionFailed()`, so
the call to `Driver#sync()` is redundant (since there are no changes
that need to be synced with the cache). This is a left-over from
before angular#43518, when `Driver#versionFailed()` used to update version
assignments and thus did require synchronization with the cache.

This commit removes the redundant `Driver#sync()` call to avoid an
unnecessary write to the cache.

PR Close angular#43680
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 cla: yes refactoring Issue that involves refactoring or code-cleanup target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants