Skip to content

fix(console): stop resolving a cyclic Error.cause chain after 10 causes - #3338

Merged
wolfib merged 1 commit into
ChromeDevTools:mainfrom
zerotohero3:fix/bound-error-cause-chain
Oct 26, 2026
Merged

wolfib merged 1 commit into
ChromeDevTools:mainfrom
zerotohero3:fix/bound-error-cause-chain

Conversation

@zerotohero3

Copy link
Copy Markdown
Contributor

Fixes #3337

SymbolizedError follows Error.cause recursively with no limit. With a cyclic chain like e.cause = e it never stops, because CDP returns a new object id for the same object on every lookup. get_console_message hangs and keeps the page queue busy, so other tools (even list_pages) are stuck until the server restarts.

This stops the lookup after 10 causes. The recursion now goes through private #fromDetails() / #fromError() that carry the depth, and the public fromDetails() / fromError() signatures stay the same. Detecting the cycle by object id doesn't work here since the ids are different every time.

What changes for users: get_console_message for Error arguments, and get_console_message / list_console_messages with includeStackTraces for uncaught errors, show at most 10 Caused by: entries. Chains with up to 10 causes look the same as before.

Testing:

  • Added a test where a mocked session keeps returning the same error with a new object id. It fails on main (actual: 50, expected: 10, the mock cuts the chain at 50 so the test fails instead of hanging) and passes with the fix.
  • npm run test passes locally (Linux, Node 24, Chrome 156).
  • Ran the repro from the issue: get_console_message comes back right away and take_snapshot / list_pages keep working.

Side note: DebuggerWorkspaceBinding.createSymbolizedError() in devtools-frontend recurses on RemoteError.cause() the same way, but chrome-devtools-mcp doesn't use it, so this fix doesn't depend on an upstream change.

SymbolizedError resolved Error.cause recursively with no limit. For a
cyclic chain such as `e.cause = e`, CDP returns a new object id on every
lookup of the same object, so the recursion never ended and
get_console_message held the page queue until the server restarted.

@wolfib wolfib left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, LGTM

@wolfib
wolfib added this pull request to the merge queue Oct 26, 2026
Merged via the queue into ChromeDevTools:main with commit 172656a Oct 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.

A page with a self-referencing Error.cause hangs get_console_message and blocks every other tool

2 participants