-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
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
[docs] Workbox & service workers are causing infinite loading of site #23874
Comments
How did you conclude that it's related to the service workers? |
Im guessing there is a connection as if you unregister the service worker line 8 in sw.js what is part of the loop: I did not investigate further, Im now. But please look into it as well. |
Also by first impression it seems to be an issue mostly if you have dev tools open from some reason. |
But I have a clear way how to reproduce this (assuming that version of os doesnt matter), latest chrome (Version 87.0.4280.88 (Official Build) (x86_64)):
|
I can't reproduce. What are your accepted languages ( |
languages: |
@huttarichard Ok thanks. I was wondering if it could come from a locale issue, it seems unlikely. |
Can somebody else reproduce? |
I've experienced similar problems related to docs and multiple tabs. Notably in development or when dealing with devtools. Though I wasn't able to reproduce them reliably. Considering the service worker also acts up in prod we should probably have an eye on it. |
@eps1lon I believe the service worker is only registered in production, could the reload be coming from somewhere else? I believe the reload can only come from two places:
I have managed to reproduce in my env by checking this box (which isn't by default): |
@oliviertassinari I think the update on reload is somewhat global option (not depending on site you currently have open). |
I could solve most of the issue with: diff --git a/docs/pages/_app.js b/docs/pages/_app.js
index 984d209fca..6b4453b3ae 100644
--- a/docs/pages/_app.js
+++ b/docs/pages/_app.js
@@ -166,6 +166,17 @@ function Analytics() {
return null;
}
+let reloadInterval;
+
+// Avoid infinite loop when "Upload on reload" is set in the Chrome sw dev tools.
+function lazyReload() {
+ clearInterval(reloadInterval);
+ reloadInterval = setInterval(() => {
+ if (document.hasFocus()) {
+ window.location.reload();
+ }
+ }, 100);
+}
+
// Inspired by
// https://developers.google.com/web/tools/workbox/guides/advanced-recipes#offer_a_page_reload_for_users
function forcePageReload(registration) {
@@ -193,7 +204,7 @@ function forcePageReload(registration) {
registration.waiting.postMessage('skipWaiting');
} else if (event.target.state === 'activated') {
// Force the control of the page by the activated service worker.
- window.location.reload();
+ lazyReload();
}
});
} It might be good enough for the problem at hand. At this point, we leverage the sw.js to have the documentation work a bit better offline. It can be handy when we have issues with our hosting provider. We used to store the whole documentation in the cache but it was too eager in bandwidth so we have moved to lazy caching. @huttarichard Do you want to try the changes for |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@Gauravkain You are good to go :) |
@oliviertassinari can you tell me what to do |
This might be related #15666. This only happens if you open two tabs. Once you do, material ui site will start loading workbox in infinite loop.
It is consuming insane amount of CPU.
It is really annoying as you are looking at docs a lot.
Unregistering service worker in chrome will solve the issue until you refresh the page.
Your Environment 🌎
OSX catalina, chrome
The text was updated successfully, but these errors were encountered: