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

Is it possible to probe event loop to see if anything is running? #2358

Closed
jprichardson opened this issue Jul 27, 2015 · 3 comments
Closed

Comments

@jprichardson
Copy link
Contributor

In Node.js:

setTimeout(function () {
  console.log(process._getActiveHandles().length)
}, 5000)

Would output 1 as the setTimeout is still on the event loop. However, in the renderer process, this returns 0. Is there a way to tap into the event loop (presumably v8) and check if anything is pending?

@mattdesl
Copy link
Contributor

If I understand this correctly, does it mean CLI tools like electron-spawn could use this to auto-quit?

If so 👍 this feature would be amazing.

@zcbenz
Copy link
Member

zcbenz commented Jul 29, 2015

Electron itself uses an async handle to implement Node.js integration so that's why process._getActiveHandles() is ways >=1 handle.

But even if we avoid creating active handles in Node.js, the Chromium itself still maintains a quite complex message loop, which means even if there is nothing active in Node.js we might still have lots of things running in Chromium.

@zcbenz
Copy link
Member

zcbenz commented May 6, 2016

I'm closing this as won't fix, because even though we can check whether there is things running in Node, we can not do it for Chromium's message loops. Many tasks of Chromium are designed to run forever, so the state of message loop can only be always running.

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

No branches or pull requests

3 participants