Skip to content

feat: add logpoints built on the DevTools BreakpointManager - #3211

Merged
OrKoN merged 17 commits into
ChromeDevTools:mainfrom
johan-gorter:feat/logpoints-breakpoint-manager
Nov 4, 2026
Merged

OrKoN merged 17 commits into
ChromeDevTools:mainfrom
johan-gorter:feat/logpoints-breakpoint-manager

Conversation

@johan-gorter

@johan-gorter johan-gorter commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Implements #2584 (logpoints) on top of the devtools-frontend logpoint code, as requested in #2584 (comment).

What

One tool, set_logpoints, in the debugging category (--category-debugging turns it off together with the other debugging tools). It takes the complete set of logpoints for the selected page as strings formatted <url>:<lineNumber>[:<columnNumber>] <expression>:

  • logpoints not in the list are removed, new ones are added, and the expression of a logpoint at an existing location is replaced; an empty list removes all logpoints;
  • url is the URL of a script as served to the browser or the path of an original source file from a source map, matched exactly or as a path suffix (e.g. src/app.ts);
  • expression is formatted like console.log() arguments and evaluated in the scope of the location (original variable names work at source-mapped locations);
  • the response lists the resulting logpoints with the generated locations they are bound to. When a location has no executable code, the other logpoints are still applied and the response lists them before the error.

Output arrives as ordinary console messages via list_console_messages. A logpoint on a line that runs during initial script evaluation can miss executions that happen before the source map is fetched after a rebuild; the tool response and the skill note say so.

How

A logpoint is a DevTools breakpoint with isLogpoint = true, created through BreakpointManager.setBreakpoint() on the BreakpointManager that the DevTools Universe of the page constructs (universe.breakpointManager). The breakpoint manager builds the backend condition, resolves original source positions through DebuggerWorkspaceBinding, substitutes minified variable names, normalizes locations (a generated location maps to its original source line) and re-binds the breakpoint when scripts and source maps re-attach after reloads and rebuilt bundles. No CDP breakpoint calls are made directly.

src/LogpointManager.ts is the adapter: it maps url onto a workspace UISourceCode (loading source maps on demand, since the universe loads them lazily), calls setBreakpoint(), and keeps the resulting Breakpoint objects; two requested locations that normalize to the same breakpoint share one entry. While logpoints exist, the lazy source-map setting of the universe is switched off so that the original sources of a rebuilt bundle re-appear and the breakpoint can re-bind.

BreakpointManager and Workspace come from the mcp.ts entrypoint (devtools-frontend CLs 8608769 and 8616700, both in the pinned submodule). src/formatters/LogpointFormatter.ts renders the result (toJSON() / toString()). src/tools/toolNames.ts holds the list_console_messages name that the tool description references.

Limitations

  • Original-source locations need source maps (--no-source-maps turns them off).
  • Only scripts of the page's main frame are supported; scripts in workers and out-of-process iframes do not match.
  • A line without executable code slides to the next valid location, as in DevTools; an original source line with no mapping is reported as an error.

Tests

  • tests/LogpointManager.test.ts: real-browser scenarios (logging without pausing, path-suffix matching, reloads; replace/remove/clear; source-mapped locations and re-binding after a rebuilt bundle; locations that normalize to the same breakpoint; unknown, ambiguous and non-executable locations) plus unit tests for parseLogpoint and validateExpression.
  • tests/tools/logpoints.test.ts: mock-based handler tests.
  • tests/formatters/LogpointFormatter.test.ts: snapshot tests.
  • tests/McpPage.test.ts: setLogpoints() with an empty list, manager reuse, and dispose().

🤖 Generated with Claude Code

@google-cla

google-cla Bot commented Oct 16, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Comment thread docs/tool-reference.md Resolved
Comment thread docs/tool-reference.md Resolved
Comment thread docs/tool-reference.md Resolved
Comment thread skills/chrome-devtools/SKILL.md Resolved
Comment thread src/tools/logpoints.ts Resolved
@johan-gorter

Copy link
Copy Markdown
Contributor Author

@OrKoN all review comments are addressed in 8a03990 (single set_logpoints tool, LogpointFormatter with toJSON/toString, list_scripts removed, skill reduced to one note).

The remaining blocker is the mcp/mcp.ts export of BreakpointManager (front_end/models/breakpoints) and the Workspace module (front_end/models/workspace). I don't have a Chromium Gerrit setup today, so if it is easiest for you to land that CL (like the recent "Export settings for MCP" change), I'll switch the PR to the official exports and drop the eslint exemptions as soon as the submodule is bumped. If you'd rather I send it, say so and I'll set up Gerrit.

I'll keep the PR as a draft until the export lands.

@OrKoN

OrKoN commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

@johan-gorter

Copy link
Copy Markdown
Contributor Author

Thanks! Once https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/8608769 lands and the submodule is bumped here, I'll switch the PR to DevTools.BreakpointManager / DevTools.Workspace and drop the direct imports, then mark it ready for review.

Comment thread src/telemetry/tool_call_metrics.json Resolved
Comment thread src/devtools/DevtoolsUtils.ts Resolved
Comment thread src/formatters/LogpointFormatter.ts Resolved
Comment thread src/tools/logpoints.ts Resolved
@OrKoN
OrKoN self-requested a review October 20, 2026 10:30
Comment thread src/tools/logpoints.ts
name: SET_LOGPOINTS_TOOL_NAME,
description: `Set the logpoints of the selected page. A logpoint logs the value of one or more expressions to the console every time a line of code executes, without pausing execution and without modifying the source code. It works like logpoints in the Chrome DevTools Sources panel and replaces temporarily instrumenting code with console.log() calls. The given list is the complete set of logpoints for the page: logpoints not in the list are removed, new ones are added and the expression of a logpoint at an existing location is replaced; an empty list removes all logpoints. Locations are given as the URL of a script as served to the browser or as an original source file (for example a TypeScript file), which is resolved through the source maps of the parsed scripts and re-resolved automatically when a rebuilt bundle is loaded. The logged output appears as regular console messages that can be read with ${LIST_CONSOLE_MESSAGES_TOOL_NAME}. Logpoints stay active across page reloads and navigations until they are removed or the page is closed. The response lists the resulting logpoints and where they are bound.`,
annotations: {
category: ToolCategory.DEBUGGING,

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.

let's create a new category and a CLI flag for logpoints per #2584 (comment) (on by default)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in c9df6db: added ToolCategory.LOGPOINTS with the generated --category-logpoints flag, on by default (--no-category-logpoints turns it off), and the tool now uses that category.

🤖 Addressed by Claude Code

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.

@johan-gorter The commit that you mention did not land on main, would you please open a new PR with the change?

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.

there is no need to create the logpoint category, we reversed this decision in the discussion on the issue.

@OrKoN
OrKoN force-pushed the feat/logpoints-breakpoint-manager branch from cee2acd to dab01ba Compare October 20, 2026 10:38

@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.

Let's address the following:

DevTools universe integration

  1. Export BreakpointManager, Workspace (UISourceCode, UILocation, projectTypes) and DebuggerModel Events from third_party/devtools-frontend/mcp/mcp.ts in a devtools-frontend CL, then remove the direct front_end/models/... imports in src/third_party/index.ts. The direct imports bypass the no-restricted-imports boundary, and mcp.ts requires foundation unit tests for each exported class.
  2. In LogpointManager.#workspace, use the universe.workspace getter instead of universe.context.get(Workspace.Workspace.WorkspaceImpl). The getter exists at the current submodule revision and removes one reason for the direct Workspace import.
  3. Fix the Common.Revealer.reveal() call in BreakpointManager.setBreakpoint() upstream (move it to the Sources panel caller), and remove registerUILocationRevealer() from src/devtools/DevtoolsUtils.ts. A model in the foundation layer must not reveal UI, and the call is void-ed, so a missing revealer causes an unhandled rejection in Node. If the upstream fix must wait, register the revealer once in the existing one-time DevTools init function, not in createTargetUniverse() with a module-level flag.
  4. Replace #ensureSourceMapsLoadOnParse() with a toggle of DevTools.SourceMapManager.lazyLoadingSettingDescriptor on universe.settings (set to false while logpoints exist, true when none exist). SourceMapManager.attachSourceMap() reads this setting on each attach, so the toggle gives eager loading without the casted 'ParsedScriptSource' event name, the instanceof DevTools.DebuggerModel check and the microtask workaround.
  5. State in the tool description that original-source locations need source maps enabled (--no-source-maps and syncSourceMaps() turn them off), and that scripts in workers and out-of-process iframes are not supported. The universe auto-starts only DebuggerModel on the main target, so these logpoints fail with "no match" or stay silently unbound.
  6. In McpPage.dispose(), clear the logpoint records without a call to breakpoint.remove(). The removal sends Debugger.removeBreakpoint after universe.dispose() on a session that is about to detach, and the page closes anyway.

Design and AGENTS.md compliance

  1. Address the open request from OrKoN: add a new tool category and a CLI flag for logpoints (on by default), per the #2584 comment. The diff still uses ToolCategory.DEBUGGING.
  2. Remove the as casts in toUserCondition() and parsedScriptSource in src/LogpointManager.ts. AGENTS.md forbids as; items 1 and 4 remove the need for the second cast.
  3. Revert the typeof tool !== 'function' skip in src/tools/tools.ts and move LIST_CONSOLE_MESSAGES_TOOL_NAME to a module that createTools() does not iterate. The skip hides real export mistakes in all tool modules.
  4. Extract the duplicated project-type filter in #sourceUrls() and #matchUISourceCode() into one helper. AGENTS.md requires one helper for repeated code.
  5. Remove the public McpPage.getLogpoints(), or give it a production caller (for example list_pages output). Only tests call it now, and AGENTS.md forbids public methods that exist only for tests.
  6. On the "No executable code" error path in setLogpoints(), add the resulting logpoint list to the response before the error. The other logpoints are applied, so the agent needs the current state.
  7. Remove the mutation record.logpoint.generatedLocations = ... in #snapshot(). The method returns a copy, so the stored field is stale state with no reader.
  8. Change the copyright year to 2026 in src/LogpointManager.ts, src/tools/logpoints.ts and tests/tools/logpoints.test.ts. These are new files.

Tests

  1. Replace the real-browser tests in tests/tools/logpoints.test.ts with mock-based handler tests (createHandlerMocks(), sinon.assert.calledOnceWithExactly(page.setLogpoints, ...)). Move the browser scenarios to tests/LogpointManager.test.ts and keep one run per scenario. AGENTS.md limits handler tests to argument checks.
  2. Add tests for McpPage.setLogpoints() with an empty list (no LogpointManager is created) and for McpPage.dispose() (records are released). No test covers these branches now.
  3. Replace assert.ok(a.includes(x) && a.includes(y)) with exact assertions or snapshots of the formatter output. Combined boolean checks hide which condition failed.

@johan-gorter

Copy link
Copy Markdown
Contributor Author

Status of the review items, all in c9df6db unless noted:

DevTools universe integration

  1. Pending the submodule bump. CL 8608769 merged on 2026-10-19 and devtools-frontend main exports BreakpointManager and Workspace from mcp.ts, but the submodule pinned by main (7a70ee1) predates it. Once the next bump lands I switch to DevTools.BreakpointManager / DevTools.Workspace and remove the direct imports. The DebuggerModel Events export is no longer needed (see 4).
  2. Done: universe.workspace getter.
  3. The upstream fix (moving Revealer.reveal() out of BreakpointManager.setBreakpoint()) needs a devtools-frontend CL; happy to send it if you want. Until then the no-op revealer is registered in overrideDevToolsGlobals() (RevealerRegistry.removeInstance() + registerRevealer), no module-level flag, nothing in createTargetUniverse().
  4. Done: lazyLoadingSettingDescriptor is set to false while logpoints exist and back to true when none remain. The parse listener, the event-name cast and the microtask workaround are gone.
  5. Done: the description states that original-source locations need source maps and that workers and out-of-process iframes are not supported.
  6. Done: dispose() only clears the records.

Design
7. Done: ToolCategory.LOGPOINTS, --category-logpoints on by default.
8. Done: no as casts remain in LogpointManager.ts. The nominal UserCondition brand is produced by an overload signature on toUserCondition().
9. Done: the typeof skip is reverted; LIST_CONSOLE_MESSAGES_TOOL_NAME lives in src/tools/toolNames.ts, which createTools() does not iterate, and console.ts imports it from there.
10. Done: one #pageSourceCodes() helper.
11. Done: McpPage.getLogpoints() is removed; tests read the state through setLogpoints().
12. Done: setLogpoints() throws a LogpointError carrying the applied logpoints; the tool appends the formatted list before rethrowing.
13. Done.
14. Done.

Tests
15. Done: tests/tools/logpoints.test.ts is mock-based (createHandlerMocks, calledOnceWithExactly); the browser scenarios moved to tests/LogpointManager.test.ts, one run per scenario (four runs).
16. Done: tests/McpPage.test.ts covers the empty list without a manager, manager reuse, and dispose().
17. Done: exact string assertions and per-field checks instead of combined includes checks.

The branch was rebased on top of your rebase of the PR branch; npm run gen and the affected test files pass locally.

@OrKoN
OrKoN self-requested a review October 20, 2026 11:00
@OrKoN

OrKoN commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

I think the submodule was bumped, please send the upstream fix after testing it in the local checkout.

Adds set_logpoint, list_logpoints, remove_logpoint and list_scripts so
agents can log runtime values at a line without pausing and without
editing source code (ChromeDevTools#2584).

Logpoints are DevTools breakpoints with isLogpoint set, created through
the BreakpointManager of the page's DevTools universe. The breakpoint
manager builds the logging condition, resolves original source files
through source maps, substitutes minified variable names and re-binds
the breakpoint when scripts and source maps re-attach after reloads and
rebuilds. LogpointManager only maps tool URLs and 1-based positions onto
workspace source codes and keeps the ids handed out to tools.

BreakpointManager and the Workspace module are not yet exported from
devtools-frontend/mcp/mcp.ts, so they are imported directly in
src/third_party/index.ts for now (marked with a TODO).
Addresses review feedback: one set_logpoints tool receives the complete
set of logpoints for the page (as "<url>:<line>[:<col>] <expression>"
strings), removes the ones left out, adds new ones and replaces the
expression at existing locations, and responds with the resulting state.
list_logpoints, remove_logpoint and list_scripts are gone; when a url
matches nothing, the error lists sources with the same file name so the
model can pick from source positions alone.

Formatting moves into LogpointFormatter with toJSON() and toString()
built from the JSON output, and the skill keeps a one-line note in the
tool selection list.
Use the BreakpointManager that the DevTools Universe creates
(universe.breakpointManager) instead of the global instance(); the
submodule bump to 7a70ee1 brought that in. Restore tool_call_metrics.json
from main and regenerate it so only set_logpoints is added. Add snapshot
tests for LogpointFormatter and reuse the exported list_console_messages
tool name from the console tools.
Add a logpoints tool category with an on-by-default --category-logpoints
flag. Use the universe's workspace getter, toggle lazy source-map loading
instead of a parse listener, register the no-op revealer in the one-time
DevTools init, and drop the cast helpers. Keep the applied logpoints in a
LogpointError so the tool can report them before failing. Replace the
browser-based handler tests with mock-based ones, move the browser
scenarios to tests/LogpointManager.test.ts and add McpPage tests for the
empty list and dispose. Move the console tool name to a module that
createTools() does not iterate.
The submodule now includes devtools-frontend CL 8608769, so the direct
front_end/models imports and their eslint exemptions are gone.
@johan-gorter
johan-gorter force-pushed the feat/logpoints-breakpoint-manager branch from c9df6db to 268b5bf Compare October 20, 2026 11:22
@johan-gorter

Copy link
Copy Markdown
Contributor Author

Done in 268b5bf: rebased onto main with the 59141dd submodule bump, switched to DevTools.BreakpointManager / DevTools.Workspace and removed the direct front_end/models imports and their eslint exemptions.

For the Revealer.reveal() fix I have a patch that removes the reveal from BreakpointManager.setBreakpoint() and moves it into DebuggerPlugin.setBreakpoint() in the Sources panel (normalize the location there and reveal it when it moved). Tested in the local checkout: with the patch applied to the submodule and the no-op revealer removed from DevtoolsUtils.ts, the logpoint tests pass. The CL goes up on Gerrit from my side shortly; once it lands and is pulled in, I drop the no-op revealer here.

@johan-gorter

Copy link
Copy Markdown
Contributor Author

Correction to my previous comment: I will not be uploading the CL myself; could you land it on the devtools-frontend side? Here is the patch, tested as described above (it applies to current main with git apply):

diff --git a/front_end/models/breakpoints/BreakpointManager.ts b/front_end/models/breakpoints/BreakpointManager.ts
index c41c053..329b522 100644
--- a/front_end/models/breakpoints/BreakpointManager.ts
+++ b/front_end/models/breakpoints/BreakpointManager.ts
@@ -330,10 +330,6 @@ export class BreakpointManager extends Common.ObjectWrapper.ObjectWrapper<EventT
           enabled, isLogpoint, origin);
 
       if (uiSourceCode === compatibleUiSourceCode) {
-        if (normalizedLocation.id() !== uiLocation.id()) {
-          // Only call this on the uiSourceCode that was initially selected for breakpoint setting.
-          void Common.Revealer.reveal(normalizedLocation);
-        }
         primaryBreakpoint = breakpoint;
       }
     }
diff --git a/front_end/panels/sources/DebuggerPlugin.ts b/front_end/panels/sources/DebuggerPlugin.ts
index f5c2141..40e25ea 100644
--- a/front_end/panels/sources/DebuggerPlugin.ts
+++ b/front_end/panels/sources/DebuggerPlugin.ts
@@ -1673,6 +1673,13 @@ export class DebuggerPlugin extends Plugin {
     const bp = await this.breakpointManager.setBreakpoint(
         this.uiSourceCode, lineNumber, columnNumber, condition, enabled, isLogpoint,
         Breakpoints.BreakpointManager.BreakpointOrigin.USER_ACTION);
+    // The breakpoint manager normalizes the location (for example to the
+    // authored file of a source-mapped script). Reveal it when it moved.
+    const uiLocation = new Workspace.UISourceCode.UILocation(this.uiSourceCode, lineNumber, columnNumber);
+    const normalizedLocation = await this.breakpointManager.debuggerWorkspaceBinding.normalizeUILocation(uiLocation);
+    if (normalizedLocation.id() !== uiLocation.id()) {
+      void Common.Revealer.reveal(normalizedLocation);
+    }
     this.breakpointWasSetForTest(lineNumber, columnNumber, condition, enabled);
     if (bp) {
       Badges.UserBadges.instance().recordAction(Badges.BadgeAction.BREAKPOINT_ADDED);

@OrKoN

OrKoN commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Yeah, we should address those. I believe in previous iterations we established that the agent should be encouraged to stringify logpoints, did it not do it for your case? that would eliminate issues with maps/sets not being visible. We should probably still think about solving that independently.

@johan-gorter

Copy link
Copy Markdown
Contributor Author

@natorion thanks for the thorough test, this matches what Opus reported above. Three fixes for this PR: (1) wrap the logged expression in try/catch so a failing logpoint reports Logpoint <url>:<line> threw: <error> instead of an empty [error] (the CDP-based fork did this and it was the most valuable part of the output); (2) correct the description: list_console_messages shows objects as [object Object], so for objects either read them with get_console_message or log JSON.stringify(x), with the Map/Set/cyclic caveat; (3) prefer the source-mapped file over a network script served at the same URL, which is the vite dev case.

@OrKoN to your question: no earlier round settled on stringify; my 2026-10-22 change said the opposite and was wrong for the list tool. Rendering object arguments as JSON in the concise console output would remove the need for either workaround, and I agree that belongs in a separate change. HMR ?t= URLs are a follow-up as well.

…served in place

A logpoint expression that throws now logs "Logpoint <url>:<line> threw:
<error>" instead of an empty error message, by evaluating the expression in
a try/catch inside the console.log() call that DevTools builds. A file that
a dev server transpiles in place, served at the URL of its original source
with a source map pointing back at it, now resolves to the original source
so that line numbers match the file on disk. The description says how
objects appear in list_console_messages and get_console_message.
@johan-gorter

Copy link
Copy Markdown
Contributor Author

The three fixes are in 4298a9f: failing expressions log Logpoint <url>:<line> threw: <error> (new test "reports a failing expression with the logpoint location"), a file served in place at the URL of its original source resolves to the source-mapped file and its line numbers (new test with an inline-source-map TypeScript file, vite dev style), and the description now says that list_console_messages shows objects as [object Object] and points to get_console_message or JSON.stringify for plain data.

🤖 Addressed by Claude Code

@OrKoN

OrKoN commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

@natorion do you have a chance to re-test on your project?

Comment thread src/tools/logpoints.ts Resolved

@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.

Please check the following items as well:

  1. Do not send a condition that starts with ... (wrapExpression() in src/LogpointManager.ts).

    • Change: Move the try/catch wrapper into devtools-frontend Breakpoint.backendCondition() after javaScriptSubstitute(), or remove the wrapper from this PR.
    • Why: backendCondition() passes the user condition to Acorn.parse() as a program; ...(() => {...})() is a SyntaxError, the .catch(() => condition) fallback skips the substitution, and original variable names at minified locations now throw ReferenceError. The tests use ts.transpileModule, which keeps the names, so they do not detect this; add a test with a generated script whose names differ from the source names.
  2. Compile the exact text that is sent to the backend in validateExpression() (src/LogpointManager.ts).

    • Change: If the wrapper stays, validate console.log(${wrapExpression(expression, '')}) instead of console.log(${expression}).
    • Why: a) + (b compiles as console.log(a) + (b) but fails inside return [a) + (b];, so the error occurs at runtime instead of at validation.
  3. Report the source-map timeout in the first branch of #findUISourceCode() (src/LogpointManager.ts).

    • Change: Set timedOut when the wait for the matched script's source map aborts, and include the retry hint or throw.
    • Why: After the timeout the logpoint is set on the transpiled script with the line numbers of the served file, which is the vite dev mismatch the PR fixes, and the response gives no hint.
  4. List the createStackTrace() behavior change in the PR description (src/devtools/DevtoolsUtils.ts).

    • Change: State that a stack trace now continues with unresolved frames when a script does not appear within 1 s, or keep the rejection from main.
    • Why: On main, .catch() without a handler passes the timeout rejection through and ConsoleFormatter drops the stack; the PR swallows the rejection, which changes list_console_messages and get_console_message output.
  5. Merge waitForMessageMatching() into waitForMessage() (tests/LogpointManager.test.ts).

    • Change: Accept string | RegExp in one helper that uses waitExecutionFor().
    • Why: The two functions repeat the same poll with different loop code; AGENTS.md requires one helper for a repeated block.

The try/catch wrapper made the condition an invalid program, so DevTools
skipped the substitution of original variable names at minified locations.
The expression is sent as given again; a test with a hand-written source
map for a minified script covers the substitution. A source map that does
not load in time for a script served at the URL of its original source now
raises an error instead of binding to the served script's lines. The stack
trace code keeps rejecting when a script does not appear in time, as on
main. The test helpers for console messages are merged into one.
@johan-gorter

Copy link
Copy Markdown
Contributor Author

All five items are in bea0953:

  1. Wrapper removed. You are right that ...(() => {...})() is not a program, so javaScriptSubstitute() was skipped. The expression is sent as given again. New test "substitutes original variable names at minified locations" uses a minified script with a hand-written source map (name → n, minMessage → m, no minifier is in the dev dependencies) and logs the original names; it fails with the wrapper and passes without it. The tool description now says that an expression that throws produces an error message without text. Reporting the error after substitution in Breakpoint.backendCondition() would be a devtools-frontend change; happy to send a patch for that as a follow-up if you want it.
  2. validateExpression() compiles console.log(${expression}), which is again exactly the text DevTools builds from LOGPOINT_PREFIX/LOGPOINT_SUFFIX.
  3. Timeout in the first branch. When the source map of the script served at the original URL has not loaded within the timeout, #findUISourceCode() now throws "The source map of was still loading after 5 seconds; retry." instead of binding to the served script's line numbers.
  4. createStackTrace() keeps the rejection from main: waitForScript() is awaited without a catch, and waitForSourceMaps() no longer swallows load errors, so a script that does not appear within 1 s still drops the stack as before. No behavior change to list in the description.
  5. One helper. waitForMessage() takes string | RegExp and uses waitExecutionFor(); waitForMessageMatching() is gone.

🤖 Addressed by Claude Code

@natorion

natorion commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

I re-tested bea09537 (npm run build) with Chrome Canary 159.0.8139.2 (--channel=canary --headless --isolated) on the same Vite + React + TypeScript app (vite dev + HMR, and vite build --sourcemap with both esbuild and terser + vite preview) and ran a fresh unscripted coding agent loop from scratch.

Here is how the agent experience looked compared to the previous test:

1.) vite dev line numbers and HMR:
Setting logpoints on vite dev using the original .ts and .tsx line numbers (src/utils/pricing.ts:60, :65, :88 and src/components/CartSummary.tsx:30) bound via the inline source map on the first try and logged the expected TypeScript variables on click. As a nice bonus, editing CartSummary.tsx during vite dev (?t=... HMR update) also kept existing logpoints firing automatically without needing a page reload. On vite dev, the unscripted agent pinpointed the bug in 10 MCP tool calls (down from 27 in the previous run) without any line-offset guesswork.

2.) Production build with source maps (vite build --sourcemap + vite preview):
Tested with both default esbuild and terser builds - logging original TypeScript variable names (subtotal, tierDiscount, promoDiscount, taxableBase, taxedTotal, appliedTags, rateLookup, computedBreakdown) against the minified bundles works cleanly on bea09537, and logpoints re-bind automatically after rebuilding and reloading.

3.) Updated set_logpoints tool description:
The updated guidance worked well for the agent. It placed logpoints after variable declaration lines right away and used JSON.stringify(...) / get_console_message on the first pass without losing a turn on [object Object]. When it logged cartSnapshot on return cartSnapshot; (pricing.ts:88) in the minified vite preview build (where the minifier had inlined cartSnapshot into return {...}), it still saw the blank [error] (0 args), but thanks to the note in the description ("an expression that throws produces an error message without text"), it immediately recognized that the variable had thrown and verified typeof cartSnapshot on the next call.

One tiny non-blocking detail: the logpoints parameter description says "a line without executable code moves to the next possible location", whereas when the agent picked blank line pricing.ts:64 on a source-mapped .ts file, that entry returned Error: No executable code at ...pricing.ts:64 (partial application still applied the other 3 logpoints, and the agent bumped 64 -> 65 on the next call).

From a user and agent UX perspective this feels solid and ready to land - lgtm

@OrKoN

OrKoN commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

@szuend could you please review the breakpoint integration in the latest version?

@szuend szuend 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.

DevtoolsUtils and LogpointManager lgtm

@OrKoN
OrKoN added this pull request to the merge queue Nov 4, 2026
Merged via the queue into ChromeDevTools:main with commit 0877ee0 Nov 4, 2026
14 checks passed
@johan-gorter

Copy link
Copy Markdown
Contributor Author

Thank you @OrKoN, @szuend and @natorion.

Most of this code was written with Claude Fable 5.1
Compliments about the review it got here! The wrapper that silently broke name substitution for minified code and the stale shared breakpoint after location normalization (OrKoN), the unbounded source-map loading and the extension content scripts (szuend), and the vite dev mismatch found by testing it with a real agent on a real app (natorion): Errors that Fable did not encounter or foresee. There is still hope for human devs 😀.

All the best for chrome-devtools-mcp.

@natorion

natorion commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Ha, well, I guided Gemini to do the testing :-)

tanishqbaweja added a commit to tanishqbaweja/chrome-devtools-mcp that referenced this pull request Nov 8, 2026
…ed-stack-traces

Resolve the conflict in createStackTrace() with the waitForSourceMaps()
refactor from ChromeDevTools#3211: the per-script wait keeps its catch and URL check,
and only the scripts that match their frames' URLs go to
waitForSourceMaps() and keep their script ids.
@OrKoN

OrKoN commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

@johan-gorter there seem to be some flakiness with the log point tests #3395 (comment) do you have an idea what might the reason? If not we will take a look.

@johan-gorter

Copy link
Copy Markdown
Contributor Author

@OrKoN thanks for the heads-up. I looked into it and I think it is a race in the logpoint code rather than in one test.

What the CI logs show

It is not only the "re-binds after a rebuilt bundle" test. The same error hits four different LogpointManager tests in the failed runs I sampled:

Run Job Test URL not found
42837357709 ubuntu, node 24 resolves original sources and re-binds after a rebuilt bundle app.ts
42852379395 macos, node 22 substitutes original variable names at minified locations min.ts
42797403722 macos, node 22 replaces, removes and clears logpoints with the complete list http://127.0.0.1:…/app.js
42690106049 macos, node 24 logs without pausing, matches path suffixes and survives reloads app.js
42199105245 macos, node 26 logs without pausing, matches path suffixes and survives reloads app.js
  • The error is always No parsed script or original source file matches "…", thrown from #findUISourceCode.
  • It is not source-map specific: plain app.js fails too.
  • It fails fast. In the first run the test took 278 ms and the message has no "still loading after 5 seconds" suffix, so the source-map wait did not time out.
  • In that run the failing call is the first setLogpoints after page.goto().

Hypothesis

page.goto() resolves on Puppeteer's CDP session, while scripts reach the DevTools DebuggerModel through the universe's own session. Nothing guarantees that Debugger.scriptParsed has been processed there when goto returns. #findUISourceCode only waits for the source maps of scripts the model already knows, so when the script is not there yet it throws immediately instead of waiting.

If that is right, it is not only test flakiness: an agent that navigates and sets a logpoint straight away can get the same error.

What I could not confirm

I did not manage to reproduce it locally (Windows, navigate + immediate setLogpoints in a loop under CPU load, about 175 iterations, 0 failures), so the mechanism above is still a hypothesis. Most CI failures are on the macOS runners.

Proposed fix

In #findUISourceCode, when nothing matches, wait for ParsedScriptSource events and re-match, bounded by the existing 5 second timeout, before throwing. That fixes the tests and the product behaviour together, instead of adding polling to the tests.

@OrKoN

OrKoN commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Trying to fix it in #findUISourceCode sounds good to me! cc @szuend

Lightning00Blade pushed a commit to jaeminbird/chrome-devtools-mcp that referenced this pull request Nov 11, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.13.0](ChromeDevTools/chrome-devtools-mcp@chrome-devtools-mcp-v1.12.0...chrome-devtools-mcp-v1.13.0)
(2026-11-11)


### 🎉 Features

* add logpoints built on the DevTools BreakpointManager
([ChromeDevTools#3211](ChromeDevTools#3211))
([0877ee0](ChromeDevTools@0877ee0))
* add page-scoped network mocks
([ChromeDevTools#3384](ChromeDevTools#3384))
([1d692d3](ChromeDevTools@1d692d3))
* support upstream network mock responses
([ChromeDevTools#3420](ChromeDevTools#3420))
([c4bf342](ChromeDevTools@c4bf342))


### 🛠️ Fixes

* **config:** accept config files with a UTF-8 BOM
([ChromeDevTools#3365](ChromeDevTools#3365))
([63170b1](ChromeDevTools@63170b1))
* **console:** stop resolving a cyclic Error.cause chain after 10 causes
([ChromeDevTools#3338](ChromeDevTools#3338))
([172656a](ChromeDevTools@172656a))
* disable set_logpoints when --no-javascript-evaluation is set
([ChromeDevTools#3415](ChromeDevTools#3415))
([11fcc59](ChromeDevTools@11fcc59)),
closes
[ChromeDevTools#3414](ChromeDevTools#3414)
* **extensions:** say list_extensions only lists unpacked extensions
([ChromeDevTools#3433](ChromeDevTools#3433))
([1383bb9](ChromeDevTools@1383bb9))
* ignore an invalid cached version in the update check
([ChromeDevTools#3392](ChromeDevTools#3392))
([3a9f378](ChromeDevTools@3a9f378))
* **input:** validate press_key and submitKey parameters in Zod schema
([ChromeDevTools#3382](ChromeDevTools#3382))
([375a269](ChromeDevTools@375a269))
* **network:** start an empty request list for navigations without a
request
([ChromeDevTools#3357](ChromeDevTools#3357))
([b701776](ChromeDevTools@b701776))
* normalize non-Error values thrown by tool handlers
([ChromeDevTools#3068](ChromeDevTools#3068))
([535a3dc](ChromeDevTools@535a3dc))
* **performance:** error when performance_stop_trace is called on a
non-recording page
([ChromeDevTools#2971](ChromeDevTools#2971))
([ChromeDevTools#3117](ChromeDevTools#3117))
([1ab630a](ChromeDevTools@1ab630a))
* **plugin:** launch the Claude Code MCP server with npx --prefix
([ChromeDevTools#3353](ChromeDevTools#3353))
([a24334d](ChromeDevTools@a24334d))
* preserve task serialization on request cancellation
([ChromeDevTools#3079](ChromeDevTools#3079))
([03fd4e8](ChromeDevTools@03fd4e8))
* report page loads that keep the URL
([ChromeDevTools#3395](ChromeDevTools#3395))
([3cc38bb](ChromeDevTools@3cc38bb))
* save binary request bodies byte for byte
([ChromeDevTools#3404](ChromeDevTools#3404))
([e3eb901](ChromeDevTools@e3eb901))
* suggest --headless when Chrome cannot find an X server
([ChromeDevTools#3428](ChromeDevTools#3428))
([8b0856a](ChromeDevTools@8b0856a))
* **url:** unwrap view-source: before all scheme checks in validateUrl
([ChromeDevTools#3335](ChromeDevTools#3335))
([7275268](ChromeDevTools@7275268))
* **wait:** explain whitespace-sensitive text matching
([ChromeDevTools#3350](ChromeDevTools#3350))
([81a0379](ChromeDevTools@81a0379))


### 📄 Documentation

* add Pi client configuration
([ChromeDevTools#3364](ChromeDevTools#3364))
([bc0d93e](ChromeDevTools@bc0d93e))
* clarify custom browser launch and connection options
([ChromeDevTools#3386](ChromeDevTools#3386))
([7e10c08](ChromeDevTools@7e10c08))
* **input:** note that press_key cannot drive native &lt;select&gt;
popups on macOS
([ChromeDevTools#3288](ChromeDevTools#3288))
([8e79bd0](ChromeDevTools@8e79bd0))


### ⚡ Performance

* **memory:** drop async parents of request initiators in
NetworkCollector
([ChromeDevTools#3345](ChromeDevTools#3345))
([ca6f834](ChromeDevTools@ca6f834)),
closes
[ChromeDevTools#3344](ChromeDevTools#3344)


### 🏗️ Refactor

* re-export only used Zod runtime members from third_party barrel
([ChromeDevTools#3439](ChromeDevTools#3439))
([6b056c8](ChromeDevTools@6b056c8))
* reuse Zod schemas and validate integer viewport dimensions
([ChromeDevTools#3367](ChromeDevTools#3367))
([3c609da](ChromeDevTools@3c609da))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: Alex Rudenko <[email protected]>
@tourealpha890-ship-it

Copy link
Copy Markdown

Cv

eacp1991 pushed a commit to eacp1991/chrome-devtools-mcp that referenced this pull request Nov 19, 2026
…ChromeDevTools#3461)

Fixes ChromeDevTools#3460.

### Problem

Setting a logpoint right after a navigation can fail with `No parsed
script or original source file matches "…"`. This is what makes the
`LogpointManager` tests flaky (see the runs listed in ChromeDevTools#3460).

A navigation is awaited on the session of the page, while scripts reach
the DevTools `DebuggerModel` through the session of the DevTools
universe. The `Debugger.scriptParsed` events can still be in flight when
the navigation is done, and `#findUISourceCode` threw right away when no
source matched.

### Fix

When nothing matches, `#findUISourceCode` now does one round trip on the
session of the universe and matches again. Events and responses of one
session are ordered, so once the response arrives the model knows every
script the page has parsed so far.

This is a bit different from what I described in
ChromeDevTools#3211 (comment).
Waiting for `ParsedScriptSource` events with a timeout would make every
mistyped URL take 5 seconds before the error with the similar file names
is reported. The round trip costs one command and only in the no-match
path. The existing source-map wait is unchanged and runs after it.

`Runtime.getHeapUsage` is used for the round trip because it is
read-only and handled in the renderer, like the debugger events. Happy
to switch to another command if you prefer one.

### Verification

- I could not reproduce the race locally (Windows, about 175 iterations
of navigate + immediate `setLogpoints` under CPU load), so there is no
regression test and the fix rests on the analysis above. CI on the macOS
runners is the real check.
- `tests/LogpointManager.test.ts` passes with the fix, and a loop of 100
navigations with an immediate `setLogpoints` passes.
- I ran the build, tests and `npm run format` with this patch applied on
the pre-GN checkout of the logpoints branch (identical
`LogpointManager.ts` and test file), because `npm run sync` does not
complete on my machine. The GN build has only run in CI.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

6 participants