Skip to content

fix(inspect): allow single-line format when breakLength is Infinity#64238

Open
hamidrezaghavami wants to merge 1 commit into
nodejs:mainfrom
hamidrezaghavami:fix-inspect-infinity-clean
Open

fix(inspect): allow single-line format when breakLength is Infinity#64238
hamidrezaghavami wants to merge 1 commit into
nodejs:mainfrom
hamidrezaghavami:fix-inspect-infinity-clean

Conversation

@hamidrezaghavami

Copy link
Copy Markdown

Description

When calling util.inspect() with a breakLength configuration explicitly set to Infinity, the internal layout formatting logic should bypass multi-line chunking and formatting constraints entirely, allowing the contents to naturally evaluate on a single line.

Currently, isBelowBreakLength goes through a character length loop calculation even when length checks are logically unnecessary due to the infinite upper bound. This change introduces an explicit early return branch within isBelowBreakLength when ctx.breakLength === Infinity, properly enabling a clean, un-wrapped single-line string formatting mode.

Checklist

  • Core internal utility verification

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Jul 1, 2026

@ljharb ljharb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this definitely needs tests to cover the changed behavior. ideally, you'd also provide the tests' output absent this change.

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

Labels

needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants