diff --git a/lib/util.js b/lib/util.js index 73f0076f6ae840..f24430d791f7c6 100644 --- a/lib/util.js +++ b/lib/util.js @@ -711,11 +711,11 @@ function formatValue(ctx, value, recurseTimes) { } catch (err) { if (errors.isStackOverflowError(err)) { ctx.seen.pop(); - process.emitWarning( - 'Inspection reached the maximum call stack size. Incomplete ' + - 'inspected object returned.' + return ctx.stylize( + `[${constructor || tag || 'Object'}: Inspection interrupted ` + + 'prematurely. Maximum call stack size exceeded.]', + 'special' ); - return ctx.stylize(`[${constructor || tag || 'Object'}]`, 'special'); } throw err; } diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index bd513ab05cb756..1f05f4987eeb41 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -1418,15 +1418,9 @@ util.inspect(process); util.inspect(list), '{ next: { next: { next: [Object] } } }' ); - common.expectWarning({ - Warning: [ - 'Inspection reached the maximum call stack size. ' + - 'Incomplete inspected object returned.', - common.noWarnCode - ] - }); const longList = util.inspect(list, { depth: Infinity }); const match = longList.match(/next/g); assert(match.length > 1000 && match.length < 10000); - assert(longList.includes('[Object]')); + assert(longList.includes('[Object: Inspection interrupted ' + + 'prematurely. Maximum call stack size exceeded.]')); }