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.

electron and web workers

See original GitHub issue

Hi, we are developing an app which runs in the browser and as an electron app. There’s been a release that has introduced this code:

if (typeof module !== 'undefined' && module.require) {
   // node.js - disable worker and set require.ensure.
   PDFJS.disableWorker = true;
   ...

The problem is that module.require exists in electron too, so web workers are disabled even if they should not. I patched pdf.js this way:

if (typeof window === 'undefined' && typeof module !== 'undefined' && module.require) {
   // node.js - disable worker and set require.ensure.
   PDFJS.disableWorker = true;
   ...

and it seems to work. I think this patch should not cause other unwanted troubles, so could it be possibile to add it to pdf.js?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Rob--Wcommented, Jan 31, 2016

What about ditching duck-typing of the environment and using typeof Worker !== 'function' instead?

0reactions
cvlmtgcommented, Apr 8, 2016

thanks, we’ll try it soon!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multithreading | Electron
With Web Workers, it is possible to run JavaScript in OS-level threads. Multi-threaded Node.js​. It is possible to use Node.js features in Electron's...
Read more >
How to run background worker processes in an Electron App
Web workers have already been around for a while and are fully supported by Chromium. As Electron is built on top of Chromium...
Read more >
trusktr/electron-web-worker-example: A bare minimal ... - GitHub
Bare minimal example that shows a Web Worker running in Electron with Node integration, meaning the Worker can use Node.js APIs (f.e. ...
Read more >
Does the electron framework allow multi-threading through ...
With Web Workers, it is possible to run JavaScript in OS-level threads. All built-in modules of Node are supported, however none of Electron's...
Read more >
electron-workers - npm
Run electron scripts in managed workers. Latest version: 1.10.3, last published: 6 years ago. Start using electron-workers in your project ...
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