electron and web workers
See original GitHub issueHi, 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:
- Created 8 years ago
- Comments:7 (3 by maintainers)
Top 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 >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
What about ditching duck-typing of the environment and using
typeof Worker !== 'function'
instead?thanks, we’ll try it soon!