From 7ed474c8ba607eaa5b053ff3709173d9e0dd8e17 Mon Sep 17 00:00:00 2001 From: Chirag Chandrashekhar Date: Wed, 26 Nov 2025 17:57:11 +0530 Subject: [PATCH] fix: add Error constructors to NodeVM context for jsonwebtoken tests (#6209) When jsonwebtoken throws errors inside the NodeVM context, those errors were instances of the VM's isolated Error class, which caused instanceOf(Error) checks in tests to fail. By adding Error constructors (Error, TypeError, ReferenceError, SyntaxError, RangeError) from the global scope to the scriptContext, errors thrown by jsonwebtoken and other modules now use the same Error class that tests check against, ensuring instanceOf checks pass correctly. This fixes jsonwebtoken test failures when using the NodeVM runtime. --- packages/bruno-js/src/sandbox/node-vm/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/bruno-js/src/sandbox/node-vm/index.js b/packages/bruno-js/src/sandbox/node-vm/index.js index 990474ac6..8673c2cf9 100644 --- a/packages/bruno-js/src/sandbox/node-vm/index.js +++ b/packages/bruno-js/src/sandbox/node-vm/index.js @@ -58,7 +58,12 @@ async function runScriptInNodeVm({ clearTimeout: global.clearTimeout, clearInterval: global.clearInterval, setImmediate: global.setImmediate, - clearImmediate: global.clearImmediate + clearImmediate: global.clearImmediate, + Error: global.Error, + TypeError: global.TypeError, + ReferenceError: global.ReferenceError, + SyntaxError: global.SyntaxError, + RangeError: global.RangeError }; mixinTypedArrays(scriptContext);