Skip to content


Subversion checkout URL

You can clone with
Download ZIP


vm.Script.runInContext has error in argument dispatch, needs documenting #1140

amb26 opened this Issue · 1 comment

2 participants


Method "vm.runInContext" or "vm.Script.runInContext" is only shadily implemented - it has an entry in vm.js and but it is not part of the official documentation and its arguments are dispatched inconsistently.

Presumably the actual intent was for the signature to be

vm.Script.runInContext(code, userContext, [filename])

this is the signature expected within jsdom -

However the argument list is handled incorrectly within, using index 1 for the filename in this case. This leads to stack traces being corrupt for such loaded code, using .toString on the context object rather than the actual filename. This also prevents the ChromeDevTools to be used to debug such an application since the string [object Context] tries to be interpreted as a filename.

@amb26 amb26 referenced this issue from a commit in amb26/node
@amb26 amb26 Node issue #1140: Fix incorrect dispatch of vm.runInContext for argum…
…ent "filename"

See #1141

@bnoordhuis bnoordhuis closed this issue from a commit
@amb26 amb26 vm: fix incorrect dispatch of vm.runInContext for argument "filename"
Adds test case and documentation for vm.runInContext and vm.createContext.

Fixes #1140.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.