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

Strange refresh behavior #10

Open
boozedog opened this issue Oct 24, 2023 · 2 comments
Open

Strange refresh behavior #10

boozedog opened this issue Oct 24, 2023 · 2 comments

Comments

@boozedog
Copy link

Thanks for the very cool proof of concept!

I am running into one strange behavior on https://richardanaya.github.io/wasm-service/

If I hold shift+refresh on this page then the service worker stops intercepting the network calls and I start getting a bunch of HTTP 405 (Method Not Allowed) errors.

To get it working again, I just have to hit refresh (without the shift key pressed).

Tested in a couple different Chromium-based browsers.

Please let me know if there's any other information I can provide!

@infogulch
Copy link
Contributor

Yes I've also noticed this, but I'm not sure exactly what to do about it. It could probably be fixed by using some particular api in a certain way, but I wasn't able to discover the correct usage.

See my notes on #5

The ServiceWorker eventually stops intercepting requests and I don't know why. This may be an error in the code, but I cleaned it up as much as possible and added logging for all relevant events and don't see any indication in code when the SW is unloaded, and it doesn't start back up automatically.

I suspect the issue is the implementation, but I have not found the culprit by combing through examples and MDN docs.

@boozedog
Copy link
Author

boozedog commented Oct 31, 2023

@infogulch I was able to get this resolved thusly:

navigator.serviceWorker
  .register("./sw.js")
  .then((reg) => {
    console.log("SW registered!", reg);
    if (!navigator.serviceWorker.controller) location.reload();
  })
  .catch((err) => console.log("Boo!", err));

(a little hacky)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants