question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

new-new-new Service worker not registering

See original GitHub issue

After a choojs/bankai#new-new-new build, in which the app.use(require('choo-service-worker')()) is uncommented and set NODE_ENV=production, the service worker does not register.

I can confirm however that the bundle.js file built by bankai does have

navigator.serviceWorker.register

If I register the serviceWorker in the index.html, rather than bundle.js then the serviceWorker registers.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
goto-bus-stopcommented, Mar 29, 2018

the technical reason is that if no service worker file is found, bankai uses an empty Buffer instead as the input for the service worker node in the graph it uses to build things. But we could add a check in lib/cmd-build.js so that empty service worker files are not written

bankai looks for sw.js and service-worker.js files in your own source and uses whichever it finds first. If you want to use some service worker implementation from npm you can create a local service worker file that only requires the one from npm:

// sw.js
require('choo-service-worker/sw')

AFAIK the sw.js in choo-service-worker is only an example and not intended to be used in this way though

1reaction
sholtomaudcommented, Sep 26, 2017

Yep, that seems to work! Brilliant!

Probably need to update create-choo-app

Read more comments on GitHub >

github_iconTop Results From Across the Web

Service Worker not registering · Issue #171 · BuilderIO/partytown
I am trying to try a POC around Partytown, but i am not able to get it working. Getting the following error.
Read more >
service worker register is not registering - Stack Overflow
I am trying to register service worker in my application. but its not being register. Code https://github.com/faisalmjanjua/PWATesting.git.
Read more >
Does not register a service worker that controls page and ...
Registering a service worker is the first step towards enabling key Progressive Web App (PWA) features: Works offline; Supports push ...
Read more >
ServiceWorkerContainer.register() - Web APIs | MDN
A string indicating how the HTTP cache is used for service worker scripts resources during updates. Note: This only refers to the service...
Read more >
Service Workers - W3C
7.1 Define API bound to Service Worker Registration ... execution lifetime of events and not references held by service worker clients to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found