sveltejs/sapper

service worker - trying to install...

Opened this issue · 3 comments

Hi, i have trouble to register/update my service worker. From the Chrome Dev Tools i see this:

C29BAC86-915E-4F3F-BA31-793F9C38B49F

My static folder is not bigger than 5MB (~ 180KB). That should not be the reason...
I have also try to fully unregistered SW in Chrome, clear Cache, restart Dev Server - but nothing changed.

But when i remove all the code in service-worker.js file, service worker can be registered. Note: I am using the default sw file, shipped with the sapper template - have not made any changes. Unfortunately I can't see the 20 displayed errors from the screenshot. In the Chrome Dev Tools none of these errors are displayed.

Environment

  • Browser: latest Chrome Version (85.x)
  • Sapper: latest Version (v0.28.3)
  • Server: Express (v4.17.x)
  • OS: macOS Catalina (10.15.x)

UPDATE
The quick temporary workaround that I applied that solved it, was to stop the service worker from caching all files in the static folder. The service worker gets stuck caching files sometimes (requests stuck at pending) even when static folder under 5 mb.

// self.addEventListener('install', event => {
// 	event.waitUntil(
// 		caches
// 			.open(ASSETS)
// 			.then(cache => cache.addAll(to_cache))
// 			.then(() => {
// 				self.skipWaiting();
// 			})
// 	);
// });

// self.addEventListener('activate', event => {
// 	event.waitUntil(
// 		caches.keys().then(async keys => {
// 			// delete old caches
// 			for (const key of keys) {
// 				if (key !== ASSETS) await caches.delete(key);
// 			}

// 			self.clients.claim();
// 		})
// 	);
// });

// always serve static files and bundler-generated assets from cache
	// if (url.host === self.location.host && cached.has(url.pathname)) {
	// 	event.respondWith(caches.match(event.request));
	// 	return;
	// }

The service worker gets stuck caching files sometimes (requests stuck at pending) even when static folder under 5 mb. The weird thing is that it only happened on Chromium browsers (Chrome, Edge)...never on Firefox. So i thing the issue is not related to sapper

Can confirm, issue only in Chromium, Firefox and Safari work fine.

Edit: seems to be a problem with Chrome 85
https://stackoverflow.com/q/61972925
https://stackoverflow.com/a/63712465

It seems it was a Chrome issue indeed, Chromium bug tracker says it's fixed and rolling out
https://bugs.chromium.org/p/chromium/issues/detail?id=1124632