I am trying to write a Node.js program to execute and monitor javascript programs. I am looking for a way to find out if a monitored program continues to "work", i.e. Do something useful.
In my current approach, when I get the code for testing, I start a new child process and pass the code to it. In the child process, the code creates a Sandbox using Contextify and executes the code using this sandbox.
After returning the call to sandbox.run(code) I know that the blocking part of the code is finished and can show it in the user interface. However, now I do not know if the code registered any timers using setTimeouts, or created other event sources that could lead to parts of the code being displayed later. Therefore, I do not know if this is really โfinishedโ.
Is there a way in Node.js to check if there are more events in the event loop to handle (or even better how much is left)?
I found this other question , but it only talks about how to track the event loop to find out if node performance is all. But I'm not interested in performance (I donโt care that the executable code blocks for 10 seconds or just does something in 1 ms every 2 minutes), and I donโt want to use external tools, but I learn about the status of the event loop from inside the node. Is it possible?
source share