bruno icon indicating copy to clipboard operation
bruno copied to clipboard

fix(#263): Implement script- & test-runtime in node:vm

Open Its-treason opened this issue 1 year ago • 3 comments

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&

Its-treason avatar Feb 10 '24 23:02 Its-treason

is it possible that we can get this merged?

tonytvo avatar Jun 28 '24 03:06 tonytvo

@helloanoop is there anything I can do to get this one merged in?

tonytvo avatar Aug 22 '24 20:08 tonytvo

@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

brvaland avatar Sep 26 '24 06:09 brvaland

@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 ?

helloanoop avatar Jun 12 '25 13:06 helloanoop

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?

Its-treason avatar Jun 12 '25 18:06 Its-treason

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 avatar Jun 17 '25 06:06 helloanoop

@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 avatar Jun 18 '25 20:06 Its-treason

@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

helloanoop avatar Sep 08 '25 05:09 helloanoop