fix(#263): Implement script- & test-runtime in node:vm
Description
Closes: #263 & #922
Implemented the existing script- & test-runtime with node:vm to deprecate vm2. All runtimes are now combined in one file / function, because the other three runtimes before shared a lot of same code.
If you want to test this locally, you have to manually activate the runtime by changing the hard-coded if (false) to true, so it uses the new runtime.
Test collection for anyone wanting to try / test it:
https://cdn.discordapp.com/attachments/1036297730483564687/1227724527752974336/VM-Test.zip?ex=66297291&is=6616fd91&hm=63637d55a57c17b3b2fff3ca34d9b17bdcd0deb734a0d685f64b17bab21bd464&
is it possible that we can get this merged?
@helloanoop is there anything I can do to get this one merged in?
@helloanoop @lohxt1 is it possible to prioritise review of this pull request to help unblock our team ?
If you can share timelines when your team will be able review will also help us plan migrate to Bruno.
Cc: @Its-treason
@Its-treason We are prioritising Node VM support to be worked on. Let us know if you'd have time to fix the conflicts and update the PR ?
Sure, I would then migrate my updated implemented from: https://github.com/Its-treason/bruno/blob/lazer/packages/bruno-core/src/request/runtime/script-runner.ts If this implementation looks good to you.
Should I leave the if (false) in the code as a feature flag?
Hey @Its-treason That sounds good. Please also remove the readme related changes in the PR.
We don't need a flag, In electron layer - we would make the change here to pass runtime as node
We still want to keep the vm2 code around in the runtime files for now.
@helloanoop I updated the PR. I'm not sure about the latest developments with the testing runtime etc. but I guess you want to update this PR anyway, so I leave the rest to you.
Furthermore, I left some TODO-comments, should be looked at. The Script runtime currently writes global variables, this could be prevented by using the runInNewContext function, but then global Objects are missing in the script.
@Its-treason We made some more changes on top of your PR here and has been merged.
We are releasing it in our upcoming version v2.11.0 in Beta. Once stable, we will make it the default for Developer Mode in a 3.x release