Skip to content
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

Getting error 404 for /service-worker.js since 1.0.0-next.207 #3159

Closed
kevinrenskers opened this issue Dec 31, 2021 · 9 comments · Fixed by #3170
Closed

Getting error 404 for /service-worker.js since 1.0.0-next.207 #3159

kevinrenskers opened this issue Dec 31, 2021 · 9 comments · Fixed by #3170
Labels
bug Something isn't working p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc. service worker Stuff related to service workers

Comments

@kevinrenskers
Copy link

kevinrenskers commented Dec 31, 2021

Describe the bug

When I updated from 203 to 210 I noticed that I was getting the following errors:

[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (service-worker.js, line 0)
[Error] Unhandled Promise Rejection: TypeError: Script http://localhost:3000/service-worker.js load failed

This happens with npm run preview and on the actual production site, so I've downgraded back to 206 for now.

Reproduction

https://github.com/kevinrenskers/sw-repro

Basically it's just the standard demo app, with adapter-node. Run npm run build and npm run preview, open the website, and look at the console.

Logs

[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (service-worker.js, line 0)
[Error] Unhandled Promise Rejection: TypeError: Script http://localhost:3000/service-worker.js load failed

System Info

System:
    OS: macOS 12.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 1.07 GB / 32.00 GB
    Shell: 3.3.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 17.0.1 - /opt/homebrew/bin/node
    npm: 8.3.0 - /opt/homebrew/bin/npm
  Browsers:
    Edge: 96.0.1054.62
    Safari: 15.2
  npmPackages:
    @sveltejs/adapter-node: next => 1.0.0-next.58
    @sveltejs/kit: next => 1.0.0-next.211
    svelte: ^3.34.0 => 3.44.3

Severity

blocking an upgrade

Additional Information

No response

@bluwy bluwy added bug Something isn't working p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc. service worker Stuff related to service workers labels Jan 1, 2022
@angrytongan
Copy link
Contributor

angrytongan commented Jan 1, 2022

Workaround: rm -rf build .svelte-kit && touch src/service-worker.js && npm run build && npm run preview

@yuanchuan
Copy link

Try to update svelte.config.js

kit: {
  /* ... */

  serviceWorker: {
    register: false,
  }

}

@kevinrenskers
Copy link
Author

kevinrenskers commented Jan 2, 2022

Thanks, that helps!

(Ignore the pre-edit text, I put the code in the wrong place)

@smithliam
Copy link

@Rich-Harris
Why do we need to do this all the time!😐

@smithliam
Copy link

Try to update svelte.config.js

kit: {
  /* ... */

  serviceWorker: {
    register: false,
  }

}

Doesn't work

@smithliam
Copy link

I see, the error that I'm getting is deferent than this one, and this issue created at 2021, not 2022 :)

This is my error message:

Not found: /service-worker.js
Error: Not found: /service-worker.js
    at resolve (file:///C:/Users/babak/Desktop/nostroid/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@sveltejs/kit/src/runtime/server/index.js:260:13)
    at resolve (file:///C:/Users/babak/Desktop/nostroid/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@sveltejs/kit/src/runtime/server/index.js:291:5)
    at Object.handle (file:///C:/Users/babak/Desktop/nostroid/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:336:66)  
    at respond (file:///C:/Users/babak/Desktop/nostroid/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@sveltejs/kit/src/runtime/server/index.js:288:40)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async file:///C:/Users/babak/Desktop/nostroid/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:406:22

@oneezy
Copy link

oneezy commented Nov 13, 2022

@smithliam i'm getting the same error on this end. anyone @here have some ideas?

@sourcegr
Copy link

@smithliam @oneezy

go to chrome://serviceworker-internals/

and click unregister at the service worker that is bound to the port you are running node (mine was 3000)

@Todaricli
Copy link

Do you guys know why this happened? I fix it by using @sourcegr 's solution, but would like to know the cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc. service worker Stuff related to service workers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants