From f709a20491d10646ff1fe28b82cb74de6206175d Mon Sep 17 00:00:00 2001 From: Hamid Reza Ghavami Date: Wed, 1 Jul 2026 19:07:08 +0300 Subject: [PATCH 1/2] fix(inspect): allow single-line format when breakLength is Infinity --- lib/internal/util/inspect.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index c959c056fece45..e3b41d763635e9 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -2624,6 +2624,8 @@ function isBelowBreakLength(ctx, output, start, base) { // TODO(BridgeAR): Add unicode support. Use the readline getStringWidth // function. Check the performance overhead and make it an opt-in in case it's // significant. + // allow the single-line format if the length limit is infinite + if ( ctx.breakLength === Infinity) return true; let totalLength = output.length + start; if (totalLength + output.length > ctx.breakLength) return false; From a10b08757017e371f6d8807120b1e31fc3a70763 Mon Sep 17 00:00:00 2001 From: Hamid Reza Ghavami Date: Thu, 2 Jul 2026 10:28:16 +0300 Subject: [PATCH 2/2] test: add test case for breakLength Infinity single-line format --- test/parallel/test-util-inspect.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 6a1da6d4129fbd..082de89c84dac9 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -4058,3 +4058,9 @@ ${error.stack.split('\n').slice(1).join('\n')}`, assert.match(inspect(DOMException.prototype), /^\[object DOMException\] \{/); delete Error[Symbol.hasInstance]; } + +{ // test case + const obj = { a: 1, b: 2, c: 3, d: 4 }; + const result = util.inspect(obj, { breakLength: Infinity }); + assert.strictEqual(result, '{ a: 1, b: 2, c: 3, d: 4 }'); +} \ No newline at end of file