Emit event when code in vm is fully executed #31240
Labels
feature request
Issues that request new features to be added to Node.js.
vm
Issues and PRs related to the vm subsystem.
wontfix
Issues that will not be fixed.
Is your feature request related to a problem? Please describe.
There is no way to know if the script running in vm is fully executed or not. Of course, all synchronous tasks are immediately executed when
runInContext
is called. But since all contexts share the event loop, we cannot tell if there are any more callbacks (of the vm code) in the event loop. (e.g. asetTimeout
callback)Describe the solution you'd like
vm.Script
should use a separate event loop and emit an event when there are no more callbacks left.Describe alternatives you've considered
As bnoordhuis stated, we can add bookkeeping to every call into the VM.
The text was updated successfully, but these errors were encountered: