Skip to content

Function has non-object prototype 'null' in instanceof check, when I use node but it is fine in Browser #35730

Closed
@jackIsZlg

Description

@jackIsZlg

Looks like a Node.js bug. Logging an object should never crash. The same works in the browser:

function X () {}
X.prototype = null;
x = {};
x.constructor = X;
console.log(x);

Node.js:

Uncaught TypeError: Function has non-object prototype 'null' in instanceof check
    at Function.[Symbol.hasInstance] (<anonymous>)
    at getConstructorName (internal/util/inspect.js:535:13)
    at formatRaw (internal/util/inspect.js:803:23)
    at formatValue (internal/util/inspect.js:793:10)
    at inspect (internal/util/inspect.js:326:10)
    at formatWithOptionsInternal (internal/util/inspect.js:1994:40)
    at formatWithOptions (internal/util/inspect.js:1878:10)
    at Object.value (internal/console/constructor.js:306:14)
    at Object.log (internal/console/constructor.js:341:61)

Browser:

{constructor: ƒ}

node Verison: v14.14.0

Metadata

Metadata

Assignees

Labels

confirmed-bugIssues with confirmed bugs.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