Skip to content

feat: make pageId routing always-on and fix waitForEventsAfterAction page isolation#1244

Closed
bcfmtolgahan wants to merge 2 commits intoChromeDevTools:mainfrom
bcfmtolgahan:main
Closed

feat: make pageId routing always-on and fix waitForEventsAfterAction page isolation#1244
bcfmtolgahan wants to merge 2 commits intoChromeDevTools:mainfrom
bcfmtolgahan:main

Conversation

@bcfmtolgahan
Copy link
Copy Markdown
Contributor

Summary

  • Remove the --experimental-page-id-routing gate so pageId is always exposed on page-scoped tools, preventing race conditions in multi-agent workflows where concurrent select_page calls cause tools to operate on the wrong page
  • Fix waitForEventsAfterAction to accept an explicit page parameter so it uses the correct page's emulation settings (CPU throttling, network conditions) instead of the global selected page
  • Update all page-scoped tool handlers (input, pages, script) to pass the explicit page to waitForEventsAfterAction

Changes

  • src/index.ts: Remove experimentalPageIdRouting gate from schema injection and page resolution
  • src/McpContext.ts: Add optional page parameter to waitForEventsAfterAction
  • src/tools/ToolDefinition.ts: Update Context interface and pageId description
  • src/tools/input.ts: Pass {page: request.page} to all 8 waitForEventsAfterAction call sites
  • src/tools/pages.ts: Pass explicit page in navigatePage and newPage; update select_page description for multi-agent guidance
  • src/tools/script.ts: Remove duplicate experimentalPageIdRouting gate, always include pageIdSchema, pass page to performEvaluation
  • src/bin/chrome-devtools-mcp-cli-options.ts: Deprecate --experimental-page-id-routing flag
  • docs/tool-reference.md, src/bin/cliDefinitions.ts: Regenerated via npm run gen

Test plan

  • E2E tests for pageId routing (screenshot, evaluate_script, navigate_page targeting correct page via pageId)
  • E2E tests for race condition simulation (interleaved select_page calls don't affect pageId-routed operations)
  • E2E tests for waitForEventsAfterAction page isolation (CPU throttling settings don't leak across pages)
  • All 544 existing tests pass with zero regressions

bcfmtolgahan and others added 2 commits March 26, 2026 17:42
…page isolation

Remove the experimental-page-id-routing gate so pageId is always exposed
on page-scoped tools. This prevents race conditions in multi-agent
workflows where concurrent select_page calls can cause tools to operate
on the wrong page.

Key changes:
- Remove experimentalPageIdRouting gate from schema injection and page
  resolution in index.ts
- Add explicit page parameter to waitForEventsAfterAction so it uses the
  correct page's emulation settings instead of the global selected page
- Update all page-scoped tool handlers (input, pages, script) to pass
  the explicit page to waitForEventsAfterAction
- Unify evaluate_script's pageId handling with the standard pattern
- Deprecate --experimental-page-id-routing CLI flag (now always enabled)
- Add E2E tests for pageId routing, race condition simulation, and
  per-page emulation isolation
Copy link
Copy Markdown
Collaborator

@OrKoN OrKoN left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Let's split the enablement of the pageId routing by default to a separate PR. Let's also move waitForEventsAfterAction to the McpPage class

@bcfmtolgahan
Copy link
Copy Markdown
Contributor Author

Thank you! Sure, splitting into two focused PRs as requested — one for removing the experimental flag, one for moving waitForEventsAfterAction to McpPage.

@OrKoN
Copy link
Copy Markdown
Collaborator

OrKoN commented Apr 1, 2026

have you also created a PR for the waitForEventsAfterAction fix?

github-merge-queue bot pushed a commit that referenced this pull request Apr 1, 2026
Splits out from #1244 per review feedback.

'waitForEventsAfterAction' previously lived in 'McpContext' and always
used the selected page's CPU/network throttling settings. With pageId
routing, a tool can target a different page than the selected one,
meaning wrong throttling multipliers were applied.

Moving the method to 'McpPage' fixes this: each tool now calls
'page.waitForEventsAfterAction(...)' and gets the correct page's
emulation settings.

'getNetworkMultiplierFromString' is extracted to 'WaitForHelper.ts' to
avoid a circular import (McpContext → McpPage already exists).

Unblocks #1777.
wolfib pushed a commit that referenced this pull request Apr 1, 2026
Splits out from #1244 per review feedback.

'waitForEventsAfterAction' previously lived in 'McpContext' and always
used the selected page's CPU/network throttling settings. With pageId
routing, a tool can target a different page than the selected one,
meaning wrong throttling multipliers were applied.

Moving the method to 'McpPage' fixes this: each tool now calls
'page.waitForEventsAfterAction(...)' and gets the correct page's
emulation settings.

'getNetworkMultiplierFromString' is extracted to 'WaitForHelper.ts' to
avoid a circular import (McpContext → McpPage already exists).

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

2 participants