Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with promises in Electron #136

Open
NotWearingPants opened this issue Nov 15, 2020 · 1 comment
Open

Not working with promises in Electron #136

NotWearingPants opened this issue Nov 15, 2020 · 1 comment

Comments

@NotWearingPants
Copy link

NotWearingPants commented Nov 15, 2020

Reproduction:

  1. Follow Electron's quick start guide to get a working electron app running (packaging not needed)
  2. npm install deasync
  3. Paste the following into the devtools in the Electron window:
    const deasync = require('deasync');
    let done = false;
    Promise.resolve().then(() => { done = true; });
    deasync.loopWhile(() => !done);
  4. The window will hang in an infinite loop

The problem seems to be that there are 3 competing event loops here: Node.js (libuv), Chrome, and V8 (for Promises).
In Node.js the Promise event loop is ran inside the libuv event loop, which means deasync runs everything when it runs the libuv loop.
And according to logic and this blogpost, in Electron the Chrome event loop is the main one, under it there is the V8 event loop and libuv event loop. Therefore running the libuv loop won't run promises.


This issue is different than #47 #64 #81 #95 because deasync is working (e.g. with sleep), but not with promises or any DOM asynchronous stuff, because of the event loop problems mentioned above.

Current versions:
Electron 10.1.5
Node.js 12.16.3
V8 8.5.210.26
Chrome 85.0.4183.121

@NotWearingPants NotWearingPants changed the title Not working in Electron Not working with promises in Electron Nov 15, 2020
@tiitremmel
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants