Search code examples
javascriptservice-workersvelterollupjssvelte-3

Weird Svelte error - missing service-worker.js - error 404


I'm kind of confused, because suddenly while running Svelte app I've got in terminal the mentioned in the title error:

  [09:37:38] 200 ─ 4.17ms ─ /
  [09:37:38] 200 ─ 0.57ms ─ /global.css
  [09:37:38] 200 ─ 1.50ms ─ /build/bundle.css
  [09:37:38] 200 ─ 2.80ms ─ /build/bundle.js
  [09:37:38] 200 ─ 1.06ms ─ /assets/logo/logo.svg
  [09:37:38] 200 ─ 1.77ms ─ /assets/icon/icon.svg
  [09:37:40] 404 ─ 0.16ms ─ /service-worker.js

I'm not even sure why the app is asking for the service-worker.js, because don't recall to have service workers configured by default with pure Svelte setup which I'm using in this project. I think service workers are installed by default with either Sapper or SvelteKit. In pure Svelte setup, there is nothing in the Rollup configuration related to service workers.

Moreover the content isn't loaded correctly in the browser sometimes. It seems like somme of the styles and/or scripts are not applied.

I was playing around with Sapper and SvelteKit a little bit, but in separated projects. Any ideas why I'm getting this kind of error?


Solution

  • It seems this is a leftover of Sapper app I was playing around, where service workers are configured out of the box.

    The solution is to unregister desired service worker. For Chrome it can be done here: chrome://serviceworker-internals/