Skip to content

Proxy bug? #31989

@tylerlong

Description

@tylerlong
const util = require('util')

const a = { b: 1 }

const p = new Proxy(a, { get: (target, prop, receiver) => {
  if(prop === util.inspect.custom) {
    return () => 'Hello world'
  }
  return target[prop]
}})

console.log(p)

Code above will output Hello world in node 10.x

It will output { b: 1 } in node 13.x

I am not sure this is by design a breaking change or a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionIssues that look for answers.utilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions