Skip to content

fix(console): do not group consecutive messages that log different objects - #3642

Merged
OrKoN merged 1 commit into
ChromeDevTools:mainfrom
KarmanyaIyer:contrib/console-group-objects
Nov 26, 2026
Merged

OrKoN merged 1 commit into
ChromeDevTools:mainfrom
KarmanyaIyer:contrib/console-group-objects

Conversation

@KarmanyaIyer

Copy link
Copy Markdown
Contributor

Summary

list_console_messages merges consecutive messages that log different objects into one line. groupConsecutive() compares type, text and argument count, and the text comes from Puppeteer's msg.text(), which renders every object argument as a fixed placeholder like [object Object]. So a loop such as items.forEach(i => console.log(i)) shows up as a single entry, and only the first message ID is listed. The other objects can only be reached by guessing their IDs for get_console_message.

#1939 kept only the first ID on the assumption that grouped messages are identical. That doesn't hold for object arguments. A number and a string with the same text (console.log(1) then console.log('1')) were also merged.

Reproduction

A page that runs:

for (const user of [{id: 1}, {id: 2}, {id: 3}]) console.log(user);
console.log(1);
console.log('1');
for (const id of [10, 20]) console.error({failedId: id});

list_console_messages on main:

msgid=1 [log] [object Object] (1 args) [3 times]
msgid=4 [log] 1 (1 args) [2 times]
msgid=6 [error] [object Object] (1 args) [2 times]

get_console_message msgid=2 returns the second object, but msgid=2 never appears in the list.

With this change all 7 messages are listed separately.

Fix

groupConsecutive() now also compares the arguments' remote objects (type, subtype, value, unserializableValue, description), the same fields DevTools compares in ConsoleMessage.isEqual. As in DevTools, an argument that is an object other than an error never compares equal. Null is treated as a plain value and still groups. Uncaught errors have no arguments, so they still group by their text as before.

User-visible changes

Both places that use groupConsecutive() change the same way: list_console_messages and the "Console errors during this call" section that navigate_page, evaluate_script and other tools append.

  • Consecutive messages that log a non-error object (plain objects, arrays, DOM nodes, Map/Set) are listed one per message instead of as [N times]. A loop that logs objects now produces N lines, so output grows in that case. Because there are fewer groups, the 10-entry cap on "Console errors during this call" can fill sooner.
  • Primitives with the same text but a different type are no longer grouped.
  • Messages that log errors with the same message but a different stack are no longer grouped.
  • Repeated identical strings, numbers, null, identical errors, and repeated uncaught errors or promise rejections still group as before.

Tests

Seven new cases in tests/formatters/ConsoleFormatterGrouping.test.ts. Three fail on main (different objects, number vs string, errors with different stacks) and pass with the fix. The others check that same strings, null, same errors and repeated uncaught errors still group.

npm run check-format and npm run build are clean. npm run test passes locally (macOS arm64, Node 24, Chrome for Testing 157). I also ran the built server against the page above and against pages logging repeated strings, repeated uncaught errors from setInterval, and repeated identical promise rejections: those still group.

Same call site is still not part of the comparison (DevTools also compares url, line and stack), so identical text logged from different lines still groups, same as main. That seemed like a separate change.

…jects

Grouping compared the message text, which renders every object argument
as `[object Object]`, so logging different objects in a loop showed as
one line and hid the other message IDs. A number and a string with the
same text were also grouped.

Like DevTools, also compare the arguments' remote objects, and never group
a message that logs an object other than an error or null. Uncaught errors
still group by their text.
@OrKoN
OrKoN enabled auto-merge November 26, 2026 18:22
@OrKoN
OrKoN added this pull request to the merge queue Nov 26, 2026
Merged via the queue into ChromeDevTools:main with commit aacf611 Nov 26, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants