Skip to content

fix(performance): error when performance_stop_trace is called on a non-recording page (#2971) - #3117

Merged
OrKoN merged 5 commits into
ChromeDevTools:mainfrom
trukhinyuri:fix/2971-stop-trace-preserve-traced-page
Nov 5, 2026
Merged

OrKoN merged 5 commits into
ChromeDevTools:mainfrom
trukhinyuri:fix/2971-stop-trace-preserve-traced-page

Conversation

@trukhinyuri

@trukhinyuri trukhinyuri commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2971

Summary

Now that McpPage.isRunningPerformanceTrace() tracks active traces per page (#3136), reject performance_stop_trace when it is called on a page that is not recording instead of issuing Page.stopTracing() against that page's CDP session. When another page is currently recording, include its page ID and a pageIdRouting-aware hint (Pass pageId: N vs Select page N with select_page first).

Verification

  • npm run build && npm run check-format
  • node --import ./build/tests/setup.js --test build/tests/tools/performance.test.js (20 passed)

@OrKoN
OrKoN requested a review from yulunz October 14, 2026 08:10
@OrKoN

OrKoN commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

@yulunz, please review this PR (automatically distributed)

@trukhinyuri
trukhinyuri force-pushed the fix/2971-stop-trace-preserve-traced-page branch from 6fb5346 to d32e552 Compare October 14, 2026 17:55

@yulunz yulunz 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 working on this! There is an ordering issue with definePageTool when performance_stop_trace is called with the closed page's pageId (Sequence B in #2971), plus a few smaller state-cleanup and test items below.

Comment thread src/tools/performance.ts Resolved
Comment thread src/McpContext.ts Resolved
Comment thread src/tools/performance.ts Resolved
Comment thread tests/tools/performance.test.ts Resolved
@trukhinyuri

Copy link
Copy Markdown
Contributor Author

Reset #tracedPageId in #resetBrowserState(), extracted getOpenPageById, converted stopTrace to defineTool so closed-page checks run before page lookup, and replaced the withMcpContext tests with unit mocks.

@OrKoN
OrKoN requested a review from yulunz October 19, 2026 13:15

@yulunz yulunz 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 updates, all four comments are addressed. Since then, #3049 landed and moved trace state onto McpPage (McpPage#setIsRunningPerformanceTrace, cleared in dispose(), with McpContext.isRunningPerformanceTrace() derived from pages). That already fixes the stuck state after the traced page closes, and it conflicts with this PR.

Could you rebase onto main and reduce this PR to the remaining part of #2971: rejecting performance_stop_trace on a page that is not recording, with a message that names the page that is (for example, check request.page.isRunningPerformanceTrace() and find the traced page through the context)? With page-level state, the McpContext#tracedPageId plumbing and the startTrace recovery branch are no longer needed. stopTrace can probably stay a definePageTool, which also removes the need to add setPage to Response and the as McpPage cast in McpResponse.setPage (AGENTS.md disallows as).

If you keep a "use pageId N" hint, please make it conditional on pageIdRouting (suggest select_page otherwise). Please also update the PR description to list the user-visible changes.

@trukhinyuri
trukhinyuri force-pushed the fix/2971-stop-trace-preserve-traced-page branch from 0db7860 to 289e02c Compare October 20, 2026 20:35
@trukhinyuri trukhinyuri changed the title fix: validate target page on performance_stop_trace and preserve recording (#2971) fix(performance): error when performance_stop_trace is called on a non-recording page (#2971) Oct 20, 2026
@trukhinyuri

Copy link
Copy Markdown
Contributor Author

@yulunz Rebased onto origin/main and simplified this to only reject performance_stop_trace when !page.isRunningPerformanceTrace(), naming the recording page and giving a pageIdRouting-aware hint (Pass pageId when pageIdRouting is enabled, or Select page ... with select_page first by default). Added unit tests covering both modes in tests/tools/performance.test.ts.

@OrKoN
OrKoN requested a review from yulunz October 21, 2026 05:02

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

LGTM. thanks for offering to fix this! We are now at a good spot for landing.

@yulunz
yulunz enabled auto-merge October 21, 2026 14:18
@trukhinyuri

Copy link
Copy Markdown
Contributor Author

Thanks for the review! After resolving the merge conflict with main, the CI workflows are awaiting maintainer approval to run.

auto-merge was automatically disabled November 1, 2026 16:53

Head branch was pushed to by a user without write access

@trukhinyuri

Copy link
Copy Markdown
Contributor Author

Merged the latest main and fixed the CI failure: stopTrace now types its factory argument as ParsedArguments (required by @local/require-parsed-arguments; without it filePath was inferred as unknown). npm run gen produces no doc changes, npm run check-format is clean, and the full test suite, notices test and memory-leak profile pass locally.

@OrKoN
OrKoN added this pull request to the merge queue Nov 5, 2026
Merged via the queue into ChromeDevTools:main with commit 1ab630a Nov 5, 2026
14 checks passed
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 <select>
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]>
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.

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

3 participants