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

User-friendly error on redundant service worker registration #32

Open
lidel opened this issue Feb 23, 2024 · 1 comment
Open

User-friendly error on redundant service worker registration #32

lidel opened this issue Feb 23, 2024 · 1 comment
Labels
need/analysis Needs further analysis before proceeding status/blocked Unable to be worked further until needs are met
Milestone

Comments

@lidel
Copy link
Member

lidel commented Feb 23, 2024

Problem

What happens when service worker gateway is used to load website which has own service worker code?

IIUC if the scope of the new service worker is the same as or a subset of the scope of the existing service worker, the new service worker will not be able to take control until the existing service worker is unregistered or its scope is changed.

AFAIK attempting to register a service worker with a conflicting scope won't result in an error, but it won't replace the existing service worker either, creating situation which is hell to debug and reason about.

Solution

  • navigator.serviceWorker registration involves sending HTTP request for worker code with `Service-Worker: script" header
  • helia-service-worker-gateway should detect such requests and return HTTP 501 Not Implemented with human-readable error, or at least link to this issue.
  • this way, registration of worker on top of existing worker won't be possible, and end user won't ever end up in broken state, and many correctly designed websites and tools should work fine (if worker was only an optional optimization for caching/offline mode).
@SgtPooki
Copy link
Member

SgtPooki commented Feb 23, 2024

Do we have an example website in this state? The only one I know of is https://helia-service-worker-gateway.on.fleek.co/ right now which you can test at https://helia--service--worker--gateway-on-fleek-co.ipfs.sw.sgtpooki.com

image

@SgtPooki SgtPooki added this to the Beta milestone Apr 8, 2024
@SgtPooki SgtPooki self-assigned this Apr 23, 2024
@SgtPooki SgtPooki added need/analysis Needs further analysis before proceeding status/blocked Unable to be worked further until needs are met labels Apr 29, 2024
@SgtPooki SgtPooki removed their assignment Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/analysis Needs further analysis before proceeding status/blocked Unable to be worked further until needs are met
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants