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.

unable to use conf inside a webworker

See original GitHub issue

Hi there,

I’m using conf inside a webworker and experiencing some issues in making it work. The webworker is initiated from Electron, but has nodeIntegrationInWorker and nodeIntegration at all places so the context there is of NodeJS, not browser ~ electron one.

(When I want to use config file from the main process of electron, Im using electron-store 😃 )

The error Im getting is the following: image After digging a little inside the error, it got me to these lines in conf’s index.js: image as you can see here, the cache deletion is being targeted at the wrong path when using the __filename , probably on runtime this special variable is being translated into this not-so-nice electron path 😞

I also tried to use electron-store (although the webworker has a node context) but it gave this error: image

Will be happy to get some advise about it, or if it’s something that needs to be added to this awesome library, I’d be happy to contribute 😎

thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
sindresorhuscommented, Mar 6, 2021

Can the try/catch also be added there? (even if inside the catch nothing special happens?)

Sure

1reaction
sindresorhuscommented, Mar 5, 2021

Yeah, we should just remove that logic as it won’t work with ESM anyway.

The problem is that it’s inconvenient for every user to have to find the path to their package.json, load the JSON, parse it, and then get those properties out of it themselves. Maybe we could add a new option called importMeta at the same time. It could accept import.meta. We could then use import.meta.url to find the package.json. I’m open to other ideas.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build fails when Web Worker dynamically imports module ...
Describe the bug. I have created a Web Worker with type: module that dynamically imports a module shared with the main thread. In...
Read more >
Running Angular 5 app inside webworker causes window ...
A worker is an object created using a constructor (e.g. Worker()) that runs a named JavaScript file — this file contains the code...
Read more >
Using Web Workers - Web APIs - MDN Web Docs
You can use most standard JavaScript features inside a web worker, including: ... The main thing you can't do in a Worker is...
Read more >
DracoCompression can not work inside web worker thread
In any case, in your PG, I think the reason why Draco doesn't work is because the Draco scripts aren't loaded in the...
Read more >
web-worker
Start using web-worker in your project by running `npm i web-worker`. There are 70 other projects in the npm registry using web-worker.
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