Service Worker not defined while accessing PWA in development
See original GitHub issueAs first reported in a PR by @cuining, this regression seems to be introduced in the move away from Parcel.
I believe this may be addressed in #3833, but some more information is still needed.
OS/Web Information
- Web Browser: Chrome
- Local OS: macOS
- Remote OS: macOS
- Remote Architecture: 64 bit
code-server --version
: 3.11.0
Steps to Reproduce
- Start code-server via
yarn watch
- Open in Chrome, add a PWA shortcut
- Refresh
Expected
No console errors should occur.
Actual
Service worker registration fails due to an invalid path. However, the file is available at an different path.
Screenshot
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:14 (10 by maintainers)
Top Results From Across the Web
Using Service Workers - Web APIs | MDN
Service workers fix these issues. Using a service worker you can set an app up to use cached assets first, thus providing a...
Read more >reference error in PWA serviceworker · Issue #7372 · go-gitea ...
UPD: that Firefox has dom.caches.enabled set to false , so the caches var is not defined on serviceworker registration.
Read more >Why is Service worker not working in Chrome? - Stack Overflow
In short: Service workers requires the site using them to be served over HTTPS for security reasons, but have execptions for localhost.
Read more >Service workers - web.dev
Before a service worker takes control of your page, it must be registered for your PWA. That means the first time a user...
Read more >Step 2 : Install a Service Worker - PWA Workshop
This means that the Service Worker has been registered. This can be verified by looking in the Application tab of Chrome Dev Tools,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ack we didn’t update this path!
https://github.com/cdr/code-server/blob/7b8cd25c0c48b6a1799587ebbc9b09d6af7988f3/src/browser/register.ts#L8
We probably didn’t notice during development because we had the old Parcel
dist
directory from previous builds.Looks like we should re-open that PR as it has the right fix.