豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

fix: list_pages should work after selected page is closed#1145

Merged
zyzyzyryxy merged 3 commits intoChromeDevTools:mainfrom
atian8179:fix/list-pages-after-close
Mar 30, 2026
Merged

fix: list_pages should work after selected page is closed#1145
zyzyzyryxy merged 3 commits intoChromeDevTools:mainfrom
atian8179:fix/list-pages-after-close

Conversation

@atian8179
Copy link
Copy Markdown
Contributor

Problem

After closing the currently selected page, calling list_pages throws an error:

The selected page has been closed. Call list_pages to see open pages.

This creates a deadlock: the error message tells users to call list_pages, but list_pages itself throws the same error.

Root Cause

list_pages is defined with definePageTool, which marks it as pageScoped: true. The handler dispatch in index.ts (line ~186) calls context.getSelectedMcpPage() for all page-scoped tools before invoking the handler. When the selected page is closed, getSelectedPptrPage() throws.

However, list_pages doesn't actually use the page parameter — its handler only calls response.setIncludePages(true).

Fix

Change list_pages from definePageTool to defineTool. This bypasses the page-scoped check while preserving all existing behavior since the handler never used the page reference.

Testing

Reproduced the issue following the steps in #1138:

  1. Call list_pages → returns page list ✅
  2. Close the selected page
  3. Call list_pages → now returns updated page list instead of throwing ✅

Fixes #1138

@google-cla
Copy link
Copy Markdown

google-cla bot commented Mar 8, 2026

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.

@zyzyzyryxy
Copy link
Copy Markdown
Contributor

Thank you for your contribution! The fix looks good, however we need your CLA status cleared first and there are some tests that need updating.

list_pages was defined with definePageTool which marks it as pageScoped.
This causes the handler dispatch in index.ts to call
getSelectedMcpPage() before invoking the handler. When the selected page
has been closed, getSelectedPptrPage() throws an error instead of
returning the page list.

list_pages doesn't actually use the page parameter — its handler only
calls response.setIncludePages(true). Change it to defineTool so it
bypasses the page-scoped check and works regardless of whether a page
is currently selected.

Fixes ChromeDevTools#1138
@atian8179 atian8179 force-pushed the fix/list-pages-after-close branch from eefe843 to 98cc530 Compare March 10, 2026 09:19
@atian8179
Copy link
Copy Markdown
Contributor Author

Thanks for the review! I've:

  1. Signed the Google CLA — should be cleared now
  2. Added a test for the fix: verifies list_pages works after the selected page is closed externally (the core scenario from list_pages tool breaks in v0.19.0 when used after closing the selected page #1138)
  3. Rebased onto latest main

Please let me know if anything else needs updating.

@zyzyzyryxy
Copy link
Copy Markdown
Contributor

The cla/google check is still failing - please see its description for a checklist of what is still needed - I think it might be about different email being associated with your commits than what you provided.

Also, tests in tests/tools/pages.test.ts need an update, they stopped compiling after your change. It should be enough to remove an extra page parameter in a few places.

Adds a test that verifies list_pages works correctly when the
currently selected page has been closed externally. This exercises
the definePageTool → defineTool change that removes the page-scoped
requirement from list_pages.

Ref ChromeDevTools#1138
@atian8179 atian8179 force-pushed the fix/list-pages-after-close branch from 98cc530 to e547ae8 Compare March 10, 2026 13:56
@atian8179
Copy link
Copy Markdown
Contributor Author

Updated — removed the extra page parameter from all listPages / listPageDef handler calls in the tests. Since list_pages is now a regular tool (not page-scoped), its handler no longer accepts the page field.

Regarding CLA: I'll check the email association and re-sign if needed.

@atian8179 atian8179 force-pushed the fix/list-pages-after-close branch from e547ae8 to 5a3e0f7 Compare March 10, 2026 13:58
@zyzyzyryxy zyzyzyryxy self-requested a review March 10, 2026 14:31
@zyzyzyryxy
Copy link
Copy Markdown
Contributor

CLA seem to be sorted out, but there are still some checks failing. Please review them and fix.

@zyzyzyryxy zyzyzyryxy enabled auto-merge March 30, 2026 08:38
@zyzyzyryxy zyzyzyryxy added this pull request to the merge queue Mar 30, 2026
Merged via the queue into ChromeDevTools:main with commit 2664455 Mar 30, 2026
17 checks passed
OrKoN pushed a commit to mvanhorn/chrome-devtools-mcp that referenced this pull request Apr 1, 2026
…ools#1145)

## Problem

After closing the currently selected page, calling `list_pages` throws
an error:
```
The selected page has been closed. Call list_pages to see open pages.
```

This creates a deadlock: the error message tells users to call
`list_pages`, but `list_pages` itself throws the same error.

## Root Cause

`list_pages` is defined with `definePageTool`, which marks it as
`pageScoped: true`. The handler dispatch in `index.ts` (line ~186) calls
`context.getSelectedMcpPage()` for all page-scoped tools **before**
invoking the handler. When the selected page is closed,
`getSelectedPptrPage()` throws.

However, `list_pages` doesn't actually use the `page` parameter — its
handler only calls `response.setIncludePages(true)`.

## Fix

Change `list_pages` from `definePageTool` to `defineTool`. This bypasses
the page-scoped check while preserving all existing behavior since the
handler never used the page reference.

## Testing

Reproduced the issue following the steps in ChromeDevTools#1138:
1. Call `list_pages` → returns page list ✅
2. Close the selected page
3. Call `list_pages` → now returns updated page list instead of throwing
✅

Fixes ChromeDevTools#1138

---------

Co-authored-by: Piotr Paulski <piotrpaulski@chromium.org>
github-merge-queue bot pushed a commit that referenced this pull request Apr 1, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.21.0](chrome-devtools-mcp-v0.20.3...chrome-devtools-mcp-v0.21.0)
(2026-04-01)


### 🎉 Features

* add a skill for detecting memory leaks using take_memory_snapshot tool
([#1162](#1162))
([d19a235](d19a235))


### 🛠️ Fixes

* **cli:** avoid defaulting to isolated when userDataDir is provided
([#1258](#1258))
([73e1e24](73e1e24))
* list_pages should work after selected page is closed
([#1145](#1145))
([2664455](2664455))
* mark lighthouse and memory as non-read-only
([#1769](#1769))
([bec9dae](bec9dae))
* **telemetry:** record client name
([9a47b65](9a47b65))
* versioning for Claude Code plugin
([#1233](#1233))
([966b86f](966b86f))
* wrap .mcp.json config in mcpServers key
([#1246](#1246))
([c7948cf](c7948cf))


### 📄 Documentation

* Command Code CLI instructions for MCP server
([0a7c0a7](0a7c0a7))
* provide disclaimer about supported browsers
([#1237](#1237))
([8676b72](8676b72))


### 🏗️ Refactor

* set process titles for easier debugging
([#1770](#1770))
([0fe3896](0fe3896))

---
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 <alexrudenko@chromium.org>
wolfib pushed a commit that referenced this pull request Apr 1, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.21.0](chrome-devtools-mcp-v0.20.3...chrome-devtools-mcp-v0.21.0)
(2026-04-01)


### 🎉 Features

* add a skill for detecting memory leaks using take_memory_snapshot tool
([#1162](#1162))
([d19a235](d19a235))


### 🛠️ Fixes

* **cli:** avoid defaulting to isolated when userDataDir is provided
([#1258](#1258))
([73e1e24](73e1e24))
* list_pages should work after selected page is closed
([#1145](#1145))
([2664455](2664455))
* mark lighthouse and memory as non-read-only
([#1769](#1769))
([bec9dae](bec9dae))
* **telemetry:** record client name
([9a47b65](9a47b65))
* versioning for Claude Code plugin
([#1233](#1233))
([966b86f](966b86f))
* wrap .mcp.json config in mcpServers key
([#1246](#1246))
([c7948cf](c7948cf))


### 📄 Documentation

* Command Code CLI instructions for MCP server
([0a7c0a7](0a7c0a7))
* provide disclaimer about supported browsers
([#1237](#1237))
([8676b72](8676b72))


### 🏗️ Refactor

* set process titles for easier debugging
([#1770](#1770))
([0fe3896](0fe3896))

---
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 <alexrudenko@chromium.org>
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.

list_pages tool breaks in v0.19.0 when used after closing the selected page

2 participants