Skip to content

Stopping a trace with another pageId, or after closing the traced page, loses the recording and returns raw Tracing.end errors #2971

Closed

Description

@coygeek

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 main at commit 5ddb0a3 (the main build).
  • 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-crux and CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS=1, and driven by a scripted stdio MCP client.

Evidence

  • Expected source: performance_start_trace response text and performance_stop_trace description in src/tools/performance.ts (both builds); docs/tool-reference.md, Performance section.
  • Failure source: scripted MCP runs above on both builds. On the main build, the running state is a single context flag (context.isRunningPerformanceTrace(), checked at src/tools/performance.ts:55 and :142), the stop path calls tracing.stop() on the page named by the request (stopTracingAndAppendOutput, src/tools/performance.ts:194-243) and clears the flag in its finally block even when Tracing.end throws, and the start handler's catch (src/tools/performance.ts:106-121) stops the page's tracing when its own tracing.start throws.
  • 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

  1. added theissue type on Oct 13, 2026
  2. coygeek commented on Nov 5, 2026

    @coygeek
    Author

    This is partly fixed. I reran the Fix check on 1.12.0 and on main at 0877ee0 with Chrome 156.0.8078.81, and both gave the same results.

    Done

    • A stop with the wrong pageId no longer loses the recording. The next performance_stop_trace {pageId:2} returns page 2's summary, and a start while the trace runs returns Error: a performance trace is already running. Use performance_stop_trace to stop it. Only one trace can be running at any given time.
    • After the traced page closes, the next start and stop on page 1 return a normal summary. The No buffer was provided error 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

    • Sequence A: performance_stop_trace {pageId:3} still returns the raw error and does not name page 2:
    Error: Protocol error (Tracing.end): Tracing is not started
    
    • Sequence B: the first stop after close_page does not say the trace ended with its page, and the stop on page 1 does not explain it either:
    stop pageId 2 -> Error: No page found
    stop pageId 1 -> Error: no active performance trace recording to stop.
    

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions