Skip to content

Attempting to console.log() DOMException.prototype throws error #60107

@samualtnorman

Description

@samualtnorman

Version

v20.19.5, v22.19.0, v24.8.0

Platform

Linux samual-nixos 6.12.48 #1-NixOS SMP PREEMPT_DYNAMIC Fri Sep 19 14:35:52 UTC 2025 x86_64 GNU/Linux

Subsystem

Console

What steps will reproduce the bug?

Evaluate console.log(DOMException.prototype) in any way.

How often does it reproduce? Is there a required condition?

Every time.

What is the expected behavior? Why is that the expected behavior?

Simply print the object to the terminal. That's what browsers do.

What do you see instead?

Welcome to Node.js v24.8.0.
Type ".help" for more information.
> console.log(DOMException.prototype)
Uncaught TypeError: Value of "this" must be of DOMException
    at throwInvalidThisError (node:internal/per_context/domexception:29:15)
    at get name (node:internal/per_context/domexception:133:7)
    at formatError (node:internal/util/inspect:1633:20)
    at formatRaw (node:internal/util/inspect:1067:14)
    at formatValue (node:internal/util/inspect:922:10)
    at inspect (node:internal/util/inspect:409:10)
    at formatWithOptionsInternal (node:internal/util/inspect:2574:40)
    at formatWithOptions (node:internal/util/inspect:2436:10)
    at console.value (node:internal/console/constructor:336:14) {
  code: 'ERR_INVALID_THIS'
}

Additional information

No response

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