fix: Add Error constructors to NodeVM context to fix jsonwebtoken test failures#6209
Merged
bijin-bruno merged 1 commit intousebruno:mainfrom Nov 26, 2025
Merged
Conversation
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.
bijin-bruno
approved these changes
Nov 26, 2025
bijin-bruno
approved these changes
Nov 26, 2025
naman-bruno
pushed a commit
to naman-bruno/bruno
that referenced
this pull request
Nov 27, 2025
…sebruno#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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When running jsonwebtoken tests with the NodeVM runtime, tests were failing because
instanceOf(Error)checks were returning false. This occurred because:jsonwebtokeninside the NodeVM context were instances of the VM's isolated Error classexpect(err).to.be.instanceOf(Error)were comparing against the outer context's Error classAdded Error constructors from the global scope to the NodeVM
scriptContext:ErrorTypeErrorReferenceErrorSyntaxErrorRangeErrorThis ensures that errors thrown by
jsonwebtokenand other modules inside the NodeVM context use the same Error class that tests check against, makinginstanceOf(Error)checks pass correctly.This PR fixes: https://usebruno.atlassian.net/browse/BRU-2083
Screenshot
Contribution Checklist: