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; diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 6a1da6d4129fbd..dcf0f0443ee709 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]; } + +{ + const obj = { long: 'a'.repeat(100), another: 'b'.repeat(100) }; + const result = util.inspect(obj, { breakLength: Infinity }); + assert.strictEqual(result.includes('\n'), false); +}