-
Notifications
You must be signed in to change notification settings - Fork 816
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
feat: workbox-window method to trigger SW update check #2136
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
} | ||
|
||
// Reset the registration time and update count so it's not treated as | ||
// external in the `this._onUpdateFound` heuristic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure resetting these here is what we want to do. Based on how I describe the intention of the "external" events in the workbox-window guide, an update found via calling update()
is (for all intents and purposes) the same as an update found via the app being updated in a new tab.
Do you disagree? Based on what you said in this comment I thought you wanted to treat them the same way: #2130 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it now but I don't understand why an update via update()
is the same as an update via a new tab? Isn't the update eventually the same as a register()
which is called after the page has been loaded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the update eventually the same as a
register()
which is called after the page has been loaded?
Not quite. The difference is register()
is always called first, and after the register()
call you either have an update or you don't. But when you have an update from the register()
call (in the same tab), it's always for a SW that is older (or the same age) as the code running on the window.
But if an update is found when calling update()
(or .register()
in another tab in the future), it means the updated SW is newer than the code running on the page, which means there could potentially be conflicts, depending on how old the code running on the page is.
Thanks, this looks good now. Do you want to try adding a test to https://github.com/GoogleChrome/workbox/blob/ba31cb87236ac4d3b1cd9c1b6580d518a6d47b73/test/workbox-window/window/test-Workbox.mjs? You can debug the window tests by running If you're not sure how to do that (or have problems getting the tests to run), I can merge your changes into another branch and add the tests myself when I get a chance. |
Okay, I added some tests... though, I couldn't find out how to actually replicate an update (i.e. a file change). Any idea or do you think these tests are enough? |
Thanks! (Sorry for the relayed reply) |
R: @jeffposnick @philipwalton
Fixes #2130
This PR introduces an
update
method on theWorkbox
instance in order to check for updates after the page has loaded. This is useful for long running applications that are seldom closed (e.g. mail applications) and where you need to check for updates on regular time interval.