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.

No Service Worker support

See original GitHub issue

I’m loading this library in a service worker and it fails to run because it attempts to use document even if it’s getCssSelector isn’t called.

I think the library should not expect these globals before it’s called.

The same happens if I try to run build/index.js in node (just as a test), except it complains about self

Can changes be made so the module doesn’t break the rest of the app by just “existing”?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
fczbkkcommented, Dec 12, 2021

Thanks for the bug report @fregante. I have created a pre-patch version v3.4.5-0, that should potentially solve the problem. It removes all references to the document object: https://www.npmjs.com/package/css-selector-generator/v/3.4.5-0

Can you please check if it works for you, before I create official patch build of the library?

1reaction
fczbkkcommented, Dec 15, 2021

Hey @fregante, can you please try v3.4.6-0?

I have reorganised the project a bit and added an ESM version. The UMD code generated by Webpack contains references to self. I don’t want to convert the original UMD build, because that would be a major breaking change.

You should be able to use the ESM version like this:

import getCssSelector from 'css-selector-generator/esm';
Read more comments on GitHub >

github_iconTop Results From Across the Web

Service worker is not supported in chrome (69.0.3497.81)
it's working fine. Chrome requires service workers to be served over https, but allows an exception for localhost for development. Share.
Read more >
Service Workers | Can I use... Support tables for ... - CanIUse
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
Read more >
Using Service Workers - Web APIs | MDN
This article provides information on getting started with service workers, including basic architecture, registering a service worker, ...
Read more >
Service workers - web.dev
Not all browsers support service workers. Even when present your service worker won't be available on first load or while it's waiting to...
Read more >
I am getting "Service workers are not supported" : r/firefox
Everything works perfectly in Chrome(ium), but not in Firefox. No matter what I do, I get "Service workers are not supported.".
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