Repository navigation
Description
Description of the bug
The server keeps one "a trace is running" flag for the whole session, while the recording itself belongs to the page it was started on. performance_stop_trace stops whichever page its pageId names. When that is not the traced page, the call fails with the raw error Protocol error (Tracing.end): Tracing is not started and clears the session flag while the real recording keeps running; the next start on the traced page then fails and discards that recording. When the traced page is closed, recovery takes two failing calls before tracing works again. In both cases the responses never say which page holds the trace.
Actual behavior
Both builds, sequence A:
start pageId 2 -> "The performance trace is being recorded. Use performance_stop_trace to stop it."
stop pageId 3 -> isError true: "Error: Protocol error (Tracing.end): Tracing is not started"
start pageId 2 -> isError true: "Error: Cannot start recording trace while already recording trace."
start pageId 2 -> "The performance trace is being recorded. ..." (page 2's first recording is gone)
stop pageId 2 -> trace summary (covers only the second recording)
Both builds, sequence B:
start pageId 2 -> "The performance trace is being recorded. ..."
close_page 2 -> page closed, page 1 selected
stop pageId 2 -> isError true: "Error: No page found"
stop pageId 1 -> isError true: "Error: Protocol error (Tracing.end): Tracing is not started"
start pageId 1 -> "The performance trace is being recorded. ..."
stop pageId 1 -> isError true: "The performance trace has been stopped.\nError: There was an unexpected error parsing the trace: No buffer was provided."
start pageId 1 -> "The performance trace is being recorded. ..."
stop pageId 1 -> normal trace summary
Reproduction
Serve any HTML page from a loopback HTTP server at http://127.0.0.1:PORT/min.html, for example <!doctype html><title>min</title><h1>Hello</h1>, and start the server under test with the flags above.
Sequence A (stop with the wrong pageId), in a fresh server:
{"name":"new_page","arguments":{"url":"http://127.0.0.1:PORT/min.html?a"}}
{"name":"new_page","arguments":{"url":"http://127.0.0.1:PORT/min.html?b"}}
{"name":"performance_start_trace","arguments":{"pageId":2,"reload":false,"autoStop":false}}
{"name":"performance_stop_trace","arguments":{"pageId":3}}
{"name":"performance_start_trace","arguments":{"pageId":2,"reload":false,"autoStop":false}}
{"name":"performance_start_trace","arguments":{"pageId":2,"reload":false,"autoStop":false}}
{"name":"performance_stop_trace","arguments":{"pageId":2}}Sequence B (close the traced page), in a fresh server:
{"name":"new_page","arguments":{"url":"http://127.0.0.1:PORT/min.html"}}
{"name":"performance_start_trace","arguments":{"pageId":2,"reload":false,"autoStop":false}}
{"name":"close_page","arguments":{"pageId":2}}
{"name":"performance_stop_trace","arguments":{"pageId":2}}
{"name":"performance_stop_trace","arguments":{"pageId":1}}
{"name":"performance_start_trace","arguments":{"pageId":1,"reload":false,"autoStop":false}}
{"name":"performance_stop_trace","arguments":{"pageId":1}}
{"name":"performance_start_trace","arguments":{"pageId":1,"reload":false,"autoStop":false}}
{"name":"performance_stop_trace","arguments":{"pageId":1}}Each sequence was run once per build with identical results; an earlier independent run of both scenarios on both builds gave the same results.
Expectation
performance_start_trace states that "Only one trace can be running at any given time" and directs the agent to "Use performance_stop_trace to stop it"; performance_stop_trace is described as "Stop the active performance trace recording on the target webpage." With one trace running, a stop request either stops and returns that trace or fails with a message that identifies the page that holds it, without losing the recording. After the traced page is closed, the next start/stop cycle on another page works, or the first call explains that the trace was lost with its page.
MCP configuration
--headless --isolated --no-usage-statistics --no-performance-crux unless the reproduction states otherwise (update checks disabled with CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS=1).
Chrome DevTools MCP version
1.10.1 (npm) and main 5ddb0a3 (local build)
Chrome version
154.0.8037.98 (stable)
Node version
v22.23.2
Operating system
macOS 27.0
Environment details
- chrome-devtools-mcp 1.10.1 from npm (the release build).
- chrome-devtools-mcp built from
mainat commit 5ddb0a3 (themainbuild). - Google Chrome 154.0.8037.98 stable, headless; Node v22.23.2; macOS 27.
- Both builds were started with
--headless --isolated --no-usage-statistics --no-performance-cruxandCHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS=1, and driven by a scripted stdio MCP client.
Evidence
- Expected source:
performance_start_traceresponse text andperformance_stop_tracedescription insrc/tools/performance.ts(both builds);docs/tool-reference.md, Performance section. - Failure source: scripted MCP runs above on both builds. On the
mainbuild, the running state is a single context flag (context.isRunningPerformanceTrace(), checked atsrc/tools/performance.ts:55and:142), the stop path callstracing.stop()on the page named by the request (stopTracingAndAppendOutput,src/tools/performance.ts:194-243) and clears the flag in itsfinallyblock even whenTracing.endthrows, and the start handler'scatch(src/tools/performance.ts:106-121) stops the page's tracing when its owntracing.startthrows. - Evidence provenance: observed
- Local verification: reproduced
- Reproduction completeness: complete
Fix check
In sequence A, performance_stop_trace {pageId:3} either returns page 2's trace or fails with a message naming page 2 as the traced page, and page 2's recording is still available to a later performance_stop_trace {pageId:2} (or was returned already). In sequence B, the first stop after close_page reports that the trace ended with its page (or returns what was recorded), and the next performance_start_trace/performance_stop_trace pair on page 1 returns a normal summary without the No buffer was provided error. As a control, a start and stop on the same page still returns a normal summary, and starting a second trace while one runs still reports that only one trace can run.
Additional context
The full open and closed issue and PR corpus was screened as of 2026-10-06. Open #808 asks for a new trace to stop an existing one automatically; it does not cover a stop on a different page or a closed traced page. Closed #2419 fixed the flag staying set when trace setup throws, a different path. A stop request with no running trace returns an empty response, which is a separate behavior from the page mismatch described here.
Activity
fix: validate target page on performance_stop_trace and preserve reco…
coygeek commentedon Nov 5, 2026
This is partly fixed. I reran the Fix check on 1.12.0 and on
mainat 0877ee0 with Chrome 156.0.8078.81, and both gave the same results.Done
pageIdno longer loses the recording. The nextperformance_stop_trace {pageId:2}returns page 2's summary, and a start while the trace runs returnsError: a performance trace is already running. Use performance_stop_trace to stop it. Only one trace can be running at any given time.No buffer was providederror no longer appears.1.11.0 on the same Chrome still shows the original failures, so this changed in 1.12.0. The review on #3117 credits #3049 for the closed-page recovery; I did not bisect.
Left
performance_stop_trace {pageId:3}still returns the raw error and does not name page 2:close_pagedoes not say the trace ended with its page, and the stop on page 1 does not explain it either:#3117 is approved and targets the wrong-page stop. I did not run it, so I don't know whether it changes the Sequence B messages.
fix(performance): error when performance_stop_trace is called on a no…
chore(main): release chrome-devtools-mcp 1.13.0 (ChromeDevTools#3349)