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

setTimeout is broken in ELECTRON_RUN_AS_NODE #22935

Closed
3 tasks done
arantes555 opened this issue Apr 2, 2020 · 3 comments
Closed
3 tasks done

setTimeout is broken in ELECTRON_RUN_AS_NODE #22935

arantes555 opened this issue Apr 2, 2020 · 3 comments

Comments

@arantes555
Copy link

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

When ELECTRON_RUN_AS_NODE is enabled, setTimeout is basically broken. It works the first time it's used, not the second time.

  • Electron Version:
    • Every version between 6.0.0 & 9.0.0-beta12
  • Operating System:
    • macOS 10.14.6 & Ubuntu 18.04
  • Last Known Working Electron version:
    • None

Expected Behavior

setTimeout should work consistently

Actual Behavior

When ELECTRON_RUN_AS_NODE is enabled, setTimeout is basically broken. It works the first time it's used, not the second time.

To Reproduce

$ git clone https://github.com/arantes555/electron-bug-settimeout.git
$ npm install
$ npm start

This runs multiple times, with the current node & with versions of electron from 6 to 9.
For a given run, it prints IT WORKED! when setTimeout works normally, and nothing otherwise.

Additional Information

Somehow, when wrapping the setTimeout in a process.nextTick, or a setImmediate, it works.

This makes me thing that it's linked to #7079 and to the activation of the uv loop in lib/common/init.ts .

@codebytere
Copy link
Member

Closing as duplicate underlying issue for #21515.

@codebytere
Copy link
Member

cc @ckerr

@arantes555
Copy link
Author

@codebytere thanks, I didn't find the other issue. I hadn't realized that it was related to using async/await at the same time as using setTimeout ...

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