sapper icon indicating copy to clipboard operation
sapper copied to clipboard

service worker - trying to install...

Open niklasgrewe opened this issue 5 years ago • 3 comments
trafficstars

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)

niklasgrewe avatar Aug 31 '20 19:08 niklasgrewe

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

niklasgrewe avatar Sep 01 '20 09:09 niklasgrewe

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

EnricoMonese avatar Sep 22 '20 00:09 EnricoMonese

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

EnricoMonese avatar Sep 22 '20 12:09 EnricoMonese