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

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

Closed
amb26 opened this issue Jun 2, 2011 · 1 comment
Closed
Labels

Comments

@amb26
Copy link

amb26 commented Jun 2, 2011

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.

amb26 added a commit to amb26/node that referenced this issue Jun 2, 2011
@amb26
Copy link
Author

amb26 commented Jun 2, 2011

See #1141

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants