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
Hello! I'm glad using this awesome library. I'm currently trying to migrate from vm2 to isolated-vm, and I'm having trouble understanding how to pass an object to the VM. Here's an example object that I want to work with:
I would like to execute some code like ( () => { app.changeStatus('Worked') } )(); and retrieve the object with the changed value { status: 'Worked' }. Could you please help me understand how to achieve this using isolated-vm?
I've tried this, but unfortunately this don't work:
I've just started looking into the migration from vm2 to isolated-vm, too. Take a look into this comment for some information that helped me proceed with my POC.
TL;DR: The integration between isolates is (a little) more effort than with vm2 and you have to think about references, copies and which code executes where. If you don't need side effects (I/O), you may get away with adding the code to the global context of the new isolate itself. However, if you want to allow the isolated code to use side effects, you can create a reference to a function that you have to call in a specific way. See the linked comment for more details.
Hello! I'm glad using this awesome library. I'm currently trying to migrate from vm2 to isolated-vm, and I'm having trouble understanding how to pass an object to the VM. Here's an example object that I want to work with:
I would like to execute some code like
( () => { app.changeStatus('Worked') } )();
and retrieve the object with the changed value{ status: 'Worked' }
. Could you please help me understand how to achieve this using isolated-vm?I've tried this, but unfortunately this don't work:
Thanks!
The text was updated successfully, but these errors were encountered: