You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a Reference to an asynchronous function in the Node isolate, that throws an error before doing any asynchronous operations, and passing it to an ivm-created isolate via a closure, the error can't be caught in that isolate when the referenced function is called.
Instead of printing "error", this will trigger an uncaught exception, hanging the Node process indefinitely. When the async keyword is removed from the referenced function or await setTimeout(); is commented in, "error" is printed as expected.
What's interesting is that it is working perfectly fine when you reverse the situation by throwing from the ivm-created isolate and catching in the Node isolate:
@nickrum We are experiencing the same.
For some reason if you use async and you return a new Promise, which you reject on error and resolve on success, it does play "nicely" (which triggers a catch inside of the isolate):
This leads me to believe that it's the first promise in the chain returned by the referenced function that, if rejected, triggers this issue. That also makes sense in the context of asynchronous functions as they are more or less wrapped in a resolved promise.
When creating a
Reference
to an asynchronous function in the Node isolate, that throws an error before doing any asynchronous operations, and passing it to an ivm-created isolate via a closure, the error can't be caught in that isolate when the referenced function is called.Here is a reproduction of the issue:
Instead of printing "error", this will trigger an uncaught exception, hanging the Node process indefinitely. When the
async
keyword is removed from the referenced function orawait setTimeout();
is commented in, "error" is printed as expected.What's interesting is that it is working perfectly fine when you reverse the situation by throwing from the ivm-created isolate and catching in the Node isolate:
In this case, "error" is printed to the console as expected.
Isolated-vm version: 4.6.0
Node version: 18.18.0
OS: Ubuntu 20.04
Compiler: gcc 9.4.0
The text was updated successfully, but these errors were encountered: