-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
vm.createContext creates more than described. #46976
Copy link
Copy link
Open
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.v8 engineIssues and PRs related to the V8 dependency.Issues and PRs related to the V8 dependency.vmIssues and PRs related to the vm subsystem.Issues and PRs related to the vm subsystem.
Metadata
Metadata
Assignees
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.v8 engineIssues and PRs related to the V8 dependency.Issues and PRs related to the V8 dependency.vmIssues and PRs related to the vm subsystem.Issues and PRs related to the vm subsystem.
Affected URL(s)
https://nodejs.org/api/vm.html#vmcreatecontextcontextobject-options
Description of the problem
See following test case:
From basic understand as document in the API this should fail, as the "console" has never been handed down into the new context.. yet it is there. Albeit the log is not working.
I guess this is a documentation issue, as the standard javascript globals are created regardless? If I hand down the console object into the created context, console.log works, but if not IMO it should either throw a call to undefined function error, or as said, the docs should describe better what is actually happening on creating a new Context.
PS: I'm aware that nodes vm.SourceTextModule probably may not be properly sandboxed, in my case this doesn't matter, I just found it confusing, the "console" object exists at all in the new context.