-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Work around "Update on Reload" infinite loop bug #5515
Conversation
When you check "Update on Reload" in Chrome Dev Tools and you configure the page to reload on every controller change, it refreshes the page in an infinite loop. We can work around this by using a variable to refresh the page only once.
Copied from the Udacity course example: https://github.com/jakearchibald/wittr/blob/page-skeleton/public/js/main/IndexController.js#L39 |
@gauntface will you be available to review this soon? |
Sorry I thought I already commented on this. If there are multiple tabs - this will only update the one page the user was currently on I.e. background tabs won't be updated, this was the main reason the messaging I was using before. Most developers seem to want that behavior of refreshing all pages, so I'm not sure we should recommend this just to get around a DevTools quirk. What do you think? |
It's also worth noting that this behaviour in Chrome Canary seems to have changes to no longer skip waiting and claim clients. |
I think you might be thinking of a different PR. This PR just adds a local I have a sample repository https://github.com/dfabulich/service-worker-refresh-sample that copies and pastes from the Advanced recipe guide; I just pushed a Here's what I did:
Are you able to find a multiple-tab bug in my sample repro? If so, can you tell me how to reproduce that bug? |
I should point out that step 3 in that list is subtle and important, because my sample doesn't call So if you skip step 3 in the first tab, the only controlled client will be the second tab; in that case, if you click the button in step 7, and then switch back to the first tab in step 8, well, it never had a controller and still doesn't, so it doesn't refresh. That's true regardless in both branches of my sample, before and after the change proposed in this PR. EDIT: It turns out that if the SW does |
@gauntface - merge if/when you're happy. |
@dfabulich closing this in favor of https://github.com/google/WebFundamentals/pull/5536/files which has the same changes. |
When you check "Update on Reload" in Chrome Dev Tools and you configure the page to reload on every controller change, it refreshes the page in an infinite loop. We can work around this by using a variable to refresh the page only once.
Target Live Date: YYYY-MM-DD
gulp test
locally and all tests pass.type-something
label.R: @petele