Skip to content

fix(mcp): bound the page-side settle wait for pages that cannot run timers - #43746

Closed
PyBgX (bgmacris) wants to merge 1 commit into
microsoft:mainfrom
bgmacris:fix/mcp-settle-csp-sandbox
Closed

PyBgX (bgmacris) wants to merge 1 commit into
microsoft:mainfrom
bgmacris:fix/mcp-settle-csp-sandbox

Conversation

@bgmacris

Copy link
Copy Markdown

Summary

  • Tab.waitForTimeout waits with a setTimeout inside the page. When the page cannot run its timers, the wait never resolves and the tool call hangs with no error and no timeout.
  • Two cases are reproduced: documents served with CSP sandbox without allow-scripts (for example every raw.githubusercontent.com file), on Chromium and WebKit; and page.clock.pauseAt() from browser_run_code_unsafe.
  • The page-side wait stays. It now races a Node-side bound of time + 5000 ms (the same bound that waitForCompletion uses for requests).

…imers

Tab.waitForTimeout waits with a setTimeout inside the page. When the page
cannot run its own timers (CSP `sandbox` without `allow-scripts`, or a page
clock paused with page.clock.pauseAt), that wait never resolves and the tool
call hangs. Race it against a Node-side bound of `time + 5000` ms.
@bgmacris

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@dgozman

Copy link
Copy Markdown
Collaborator

Please file an issue before submitting a PR, according to the CONTRIBUTING.md.

@bgmacris

Copy link
Copy Markdown
Author

Thanks, and sorry for skipping that step. Filed #43752 with a minimal repro.

Gabriel (gabriel-diagram) pushed a commit to gabriel-diagram/quimera-ai that referenced this pull request Nov 16, 2026
…annot run scripts

@playwright/mcp 0.0.83 ends each action with a setTimeout inside the page. A document served
with CSP `sandbox` (every raw.githubusercontent.com file) never runs it, so browser_evaluate,
browser_click & co. never return (2 of 5 research runs of the tandem-vs-Firecrawl bench hung
reading READMEs). Fix proposed upstream: microsoft/playwright#43746.

Until it ships, the autostart hook probes the current tab (sync evaluate, then a microtask over
the browser endpoint: hidden tabs delay timers, never microtasks) before the 12 tools that go
through that wait, and denies them with what to do instead (browser_snapshot, or fetch() from a
normal page). Unsure which tab, or the page is busy → allow. ~20 ms per guarded call;
TANDEM_SANDBOX_GUARD=0 turns it off.

Co-Authored-By: Claude Opus 5.5 <[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.

2 participants