Skip to content

util.inspect/console.log: classes print as bare integers, holes as NaN, resolved promises as pending #9415

Description

@proggeramlug
console.log(class Klass {})       // node "[class Klass]"        perry "49"  (a bare integer)
console.log(new Array(3))         // node "[ <3 empty items> ]"  perry "[ NaN, NaN, NaN ]"
console.log(Promise.resolve(1))   // node "Promise { 1 }"        perry "Promise { <pending> }"

Three distinct inspect defects. The first is the worst: a class value prints as an integer (its class id leaking through), which is unrecognisable rather than merely differently formatted. The second turns holes into NaN, which is a wrong value, not a formatting choice. The third reports a settled promise as pending.

Debug output is how people diagnose everything else, so these make every other investigation harder.

Found by a differential stress-test of claude-code under perry.

Activity

  1. proggeramlug commented on Sep 2, 2026

    @proggeramlug
    ContributorAuthor

    Fixed by PR #9461: classes print [class Name] (the INT32/class-ref tag ambiguity, resolved via the shared value_repr classifier that #9472 also standardized #9465's fix onto), holes render <N empty items>/undefined instead of NaN in both array walks and Map/Set, and promise state is read (Promise { 1 }, <rejected>). test_gap_9415_inspect_class_hole_promise.ts. Verified on main 0a1c137d90 with a fresh build: fixture byte-identical to node --experimental-strip-types (stdout, stderr, and exit code).
    The rest of the fall-through-to-double family is filed as #9462 (hole-leak source + typeof/String/console.table) and #9463 (%s/%o policy).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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