Skip to content

Weird Proxy internal util.inspect error #25212

Closed
@LJNeon

Description

@LJNeon
  • Version: v10.14.2 & v11.5.0
  • Platform: Linux
  • Subsystem: inspect?

The following code:

let thing;
thing = new Proxy(() => {}, {
  get() {
    return thing;
  },
  apply() {
    return thing;
  }
});
console.info(thing);

emits the following error when executed:

internal/util/inspect.js:594
      const name = `${type}${value.name ? `: ${value.name}` : ''}`;
                                                     ^

TypeError: Cannot convert object to primitive value
    at formatRaw (internal/util/inspect.js:594:54)
    at formatValue (internal/util/inspect.js:508:10)
    at inspect (internal/util/inspect.js:191:10)
    at Object.formatWithOptions (util.js:84:12)
    at Console.(anonymous function) (console.js:188:15)
    at Console.log (console.js:199:31)
    at Object.<anonymous> (/home/ubuntu/workspace/thread/index.js:12:9)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)

If I remove either the get() or the apply() it works, but when both are set it errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions