Skip to content

util.inspect different in vm #4080

Closed
Closed
@jbr

Description

@jbr

I'm not entirely sure if this is a bug or my misunderstanding, but I was surprised to discover that these two expressions have different values in the 5.1.0 node repl:

vm.runInNewContext("util.inspect({})", { util: util }) //=> 'Object {}'
util.inspect({}) //=> '{}'

or for standalone examples outside of the repl:

bash> node -pe "require('vm').runInNewContext('util.inspect({})', { util: require('util') })"
Object {}
bash> node -pe "require('util').inspect({})"
{}

Is this intended behavior? Is there a way to get the repl equivalent result from util.inspect in a vm without resorting to string replacement?

Metadata

Metadata

Assignees

No one assigned

    Labels

    utilIssues and PRs related to the built-in util module.vmIssues and PRs related to the vm subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions