Skip to content

feat(list_console_messages): include source-mapped location of messages - #960

Closed
kopalg20 wants to merge 3 commits into
ChromeDevTools:mainfrom
kopalg20:fix-async-source-map-fetch
Closed

kopalg20 wants to merge 3 commits into
ChromeDevTools:mainfrom
kopalg20:fix-async-source-map-fetch

Conversation

@kopalg20

Copy link
Copy Markdown

I implemented async fetching of source-mapped locations for console messages and uncaught errors.

  • list_console_messages remains fast and non-blocking.

  • get_console_message returns detailed stack traces with resolved source-mapped top frames.

  • Verified with 3000+ simulated errors; performance remains acceptable.

This addresses the request to show the source-mapped location for errors directly, without having to manually parse the stack trace.

Made the changes in src/formatters/ConsoleFormatter.ts

Screenshot 2026-02-14 012632 Screenshot 2026-02-14 012622

@kopalg20 kopalg20 closed this Feb 13, 2026
@kopalg20 kopalg20 changed the title Enhance list_console_messages to show originating source location for console messages (#903) feat(list_console_messages): include source-mapped location of messages Feb 13, 2026
@kopalg20 kopalg20 reopened this Feb 13, 2026

@OrKoN OrKoN left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the PR, could you please add tests?

Comment thread src/formatters/ConsoleFormatter.ts Outdated
}

toJSONDetailed(): object {
const location = this.#getTopFrameLocation();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the feature is about adding the first line of the stack to the non-detailed variants (toString(), toJSON()) so that the first source line appears in the list of console message. toJSONDetailed is not used in list_console_messages.

@kopalg20 kopalg20 Feb 13, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Made required changes. Let me know any further improvements needed.
Also added test cases for the same. @OrKoN

@OrKoN OrKoN left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tests and linter need to be fixed.

});
});

describe('ConsoleFormatter - Source Map & Heavy Error Tests', () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

these tests do not use any source maps. Can we also embed them into existing tests that already verify console message details and cover the list expectations there too?

@OrKoN

OrKoN commented Feb 26, 2026

Copy link
Copy Markdown
Collaborator

Closing as stale.

@OrKoN OrKoN closed this Feb 26, 2026
masamaru0513 added a commit to masamaru0513/chrome-devtools-mcp that referenced this pull request May 15, 2026
Address reviewer feedback on PR ChromeDevTools#2060:
- Resolve source-mapped location via the stack trace's top non-ignored
  frame using uiSourceCode.uiLocation(), similar to the approach in ChromeDevTools#960.
- Use the short display name (filename:line:col) for the concise text
  output to keep token usage low; full URL is preserved in the
  structured JSON output.
- Include source location in the grouping key so that messages with
  identical text but different origins do not collapse together.
- Bound stack-trace resolution with a timeout so a hanging page (e.g.
  blocked on a dialog) does not stall the tool call; falls back to the
  raw msg.location() / exceptionDetails location.
- Split SymbolizedError.fromDetails' `includeStackAndCause` into
  `includeStack` and `includeCause` so the formatter can fetch the
  stack for location resolution without paying for cause lookup.
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.

3 participants