Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

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

Description

@amb26

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

http://nodejs.org/docs/v0.4.8/api/all.html#executing_JavaScript

Presumably the actual intent was for the signature to be

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

this is the signature expected within jsdom -

https://github.com/tmpvar/jsdom/blob/master/lib/jsdom/level2/languages/javascript.js

However the argument list is handled incorrectly within node_script.cc, 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions