Repository navigation
fix: fail fast on tool calls stuck after a dead browser connection - #2699
Conversation
|
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. |
270c579 to
6d2d4e9
Compare
samiyac
left a comment
There was a problem hiding this comment.
Thank you for the PR. I have added some initial review comments.
OrKoN
left a comment
There was a problem hiding this comment.
Critical Bugs & Architectural Issues
1. Timeout Only Wraps tool.handler(), Leaving response.handle() and getContext() Unbounded Inside toolMutex
- Location:
src/ToolHandler.ts:238-297 - Problem:
#runToolWithTimeout()only wrapsthis.tool.handler(...). However, insidethis.toolMutex.acquire(), three major phases talk to CDP:- Tools whose CDP calls happen inside
response.handle()will still hang forever:
Many tools do not make CDP calls insidetool.handler(); instead, their handler synchronously sets a flag onMcpResponseand resolves in<1ms, while the actual CDP calls execute inawait response.handle(context, dataFormat)(line 294, outside#runToolWithTimeout):take_snapshot:handleronly callsresponse.includeSnapshot();TextSnapshot.create()(Accessibility.getFullAXTree) runs inresponse.handle().list_pages:handleronly callsresponse.setIncludePages(true);context.createPagesSnapshot()(browser.pages()) runs inresponse.handle().get_network_request:handleronly callsresponse.attachNetworkRequest(reqid);httpResponse.buffer()(Network.getResponseBody) runs inresponse.handle().list_extensions:handleronly callsresponse.setListExtensions(true);context.listExtensions()runs inresponse.handle().
If the CDP transport is silently dead, all of these tools will bypass#runToolWithTimeoutand hang indefinitely inresponse.handle(), deadlockingtoolMutex.
- Post-timeout fallthrough into
response.handle():
Whenthis.tool.handler()does time out after 60s, thecatch (err)block at line 281 catchesToolCallTimeoutError, callsresponse.setError(err), and continues execution to:devToolsData = await context.getDevToolsData(page)(which adds an extra 500ms timeout wait on the dead browser), andawait response.handle(context, dataFormat)(line 294).
If the timed-out handler had already calledresponse.includeSnapshot()orresponse.setIncludePages(true)before hanging,McpResponse.handle()will attempt to query CDP on the deadcontext/pageand hang forever after the 60s timeout has already fired.
- Unbounded
this.getContext():
await this.getContext()(line 238) runs insidethis.toolMutex.acquire()but outside#runToolWithTimeout(). Ifpuppeteer.connect()orMcpContext.from()(browser.pages()) hangs on a half-open socket during initial connect or reconnect,getContext()hangs forever while holdingtoolMutex.
- Tools whose CDP calls happen inside
- Recommendation:
- Either wrap the entire CDP-interacting section inside
toolMutex.acquire()(includinggetContext(),tool.handler(), andresponse.handle()) with the timeout, or - Immediately return the error
CallToolResultfromhandle()whenToolCallTimeoutErroris caught (do not fall through togetDevToolsDataandresponse.handle()), AND includeresponse.handle()within#runToolWithTimeout().
- Either wrap the entire CDP-interacting section inside
2. Resource Leak & Uncancelled Hung Promises in forgetBrowser()
- Location:
src/browser.ts:216-221andsrc/ToolHandler.ts:130-132 - Problem:
- In
src/browser.ts,forgetBrowser(candidate)setsbrowser = undefined; browserMode = undefined;without disconnecting or closingcandidate. - If
browserMode === 'launched', dropping the reference without callingcandidate.close()leaves an orphaned Chrome subprocess (candidate.process()) running in the background. - If
browserMode === 'connected', dropping the reference without callingcandidate.disconnect()leaves the WebSocket transport and event listeners open in memory. - Furthermore, the comment in
src/ToolHandler.ts:130-132states:The loser of the race (a genuinely hung handler) is left running; there is no way to cancel a pending Puppeteer call...
In fact, callingcandidate.disconnect()(orcandidate.close()) does cancel all pending Puppeteer CDP calls: Puppeteer'sConnectiondisposal synchronously rejects all in-flight CDP callbacks withTargetCloseError/Connection closed. Actively disconnecting/closing the forgotten browser on timeout will immediately settle the hung handler promise and allow itsfinallyblocks /DisposableStack(e.g. element handles) to clean up instead of leaking in memory.
- In
- Recommendation: In
forgetBrowser(candidate)(or when handling a timeout), actively tear downcandidatein the background: callvoid candidate.close().catch(() => {})if launched, orvoid candidate.disconnect().catch(() => {})if connected.
AGENTS.md Rule Violations
3. Non-Null Assertion Operator (!) in src/ToolHandler.ts
- Location:
src/ToolHandler.ts:154(clearTimeout(timer!);) - Rule:
AGENTS.md-> Rules for TypeScript:"Do not use ! operator for type assertion." - Fix: Declare
let timer: ReturnType<typeof setTimeout> | undefined;and callclearTimeout(timer);(clearTimeout(undefined)is a safe no-op in Node.js).
4. Type Casting (as) and Hand-Rolled Mock in tests/browser.test.ts
- Location:
tests/browser.test.ts:442(forgetBrowser({} as Browser);) - Rule:
AGENTS.md-> Rules for TypeScript:"Do not use as keyword for type casting."and Mocking Guidelines:"Do not hand-roll mock objects... Use sinon.createStubInstance()"/"Centralize mocks in tests/mocks.ts". - Fix: Use
getMockBrowser()fromtests/utils.js/tests/mocks.js.
5. Node assert Instead of sinon.assert for Spy Verification in tests/ToolHandler.test.ts
- Location:
tests/ToolHandler.test.ts:315-318and365assert.strictEqual( forgetBrowserSpy.calledOnceWith(mockContext.browser), true, ); ... assert.strictEqual(forgetBrowserSpy.called, false);
- Rule:
AGENTS.md-> Assertions and Sinon Best Practices:Use
sinon.assertmethods: Do not use Node'sassert.ok(stub.calledOnce)orassert.deepStrictEqual(stub.firstCall.args[0], ...)to verify stub calls.- Use
sinon.assert.calledOnceWithExactly(stub, ...args)for single calls with exact arguments. - Use
sinon.assert.notCalled(stub)to assert a method was not invoked.
- Use
- Fix: Replace with:
sinon.assert.calledOnceWithExactly(forgetBrowserSpy, mockContext.browser); ... sinon.assert.notCalled(forgetBrowserSpy);
Addresses items 1.i and 1.ii from OrKoN's PR review (ChromeDevTools#2699 (review)): 1.i: `#runToolWithTimeout` only wrapped `tool.handler()`. Several tools' actual CDP calls happen in `response.handle()` instead (`take_snapshot`, `list_pages`, `get_network_request`, `list_extensions`) — those tools got no protection at all against the bug this fix exists to prevent. 1.ii: even when `tool.handler()` did time out, execution still fell through to `getDevToolsData()`/`response.handle()` afterward — a second, separate, unprotected call that could hang again on the same dead connection, this time with no timeout at all. Note what "fixed" means here: the abandoned execution that ends up hanging (whichever phase it's in) never actually resolves — JS has no cancellation, so a dead CDP call still hangs forever, unlistened-to. What's fixed is that `handle()`'s own control flow no longer waits on a *second* unprotected hang after the first timeout — it's bounded by one shared 60s budget, so `toolMutex` reliably gets released and the caller reliably gets a response, instead of the original total-lockup bug reproducing itself one call later. `ToolHandler.ts`: the sequence that used to run after the timeout-wrapped `tool.handler()` call — `getDevToolsData`/`pageUrl`/`dataFormat` resolution, then `response.handle()` — now runs inside the same closure passed to `#runToolWithTimeout`, so both phases share one 60s budget. A timeout at any point rejects with `ToolCallTimeoutError`, which propagates straight to the existing outer `catch` — `devToolsData`/`response.handle()`'s result are simply never used once that happens, no new early-return needed. `page` moved to a closure-local (previously hoisted, which would have needed a non-null assertion here — an AGENTS.md violation). Also documents, at the `getContext()` call site, why item 1.iii (unbounded `getContext()`) is deliberately not covered by this change: `puppeteer.connect()` has no cancellation mechanism (confirmed against `ConnectOptions.d.ts` — no `signal`/timeout option), so racing it would trade a known hang for an abandoned connection that could later resolve and silently clobber whatever browser state exists by then. Left for a follow-up that needs its own design, not a simple timeout wrap. `tests/ToolHandler.test.ts`: new test covering the actual regression for 1.i — a tool whose `handler()` resolves immediately but whose `response.handle()` hangs (stubbed via `McpResponse.prototype.handle`) still times out, returns an error, and forgets the browser.
Addresses item 1.iii from OrKoN's PR review (ChromeDevTools#2699 (review)): `getContext()` had no timeout at all, so a hung `puppeteer.connect()` reproduced the original bug — `toolMutex` never released, every subsequent call queued forever. A bare timeout wrap isn't safe here the way it was for 1.i/1.ii: `puppeteer.connect()` has no `signal`/timeout option and cannot be cancelled (confirmed against `ConnectOptions.d.ts`), so racing it only stops us from waiting — the attempt keeps running abandoned. If it later succeeded anyway, the old unconditional `browser = connected;` would silently overwrite whatever a subsequent, independent call had already established — trading a known hang for a harder-to-diagnose state-corruption bug. `browser.ts`: added an identity token (`currentBrowserAttempt`) and `abandonPendingBrowserAttempt()`. `ensureBrowserConnected()`/ `ensureBrowserLaunched()` snapshot the token before connecting/launching and re-check it after — a mismatch means someone gave up waiting, so the result is disconnected/closed and discarded instead of installed. Also applied to `ensureBrowserLaunched()`, though a code comment notes that's currently defensive rather than load-bearing: `launch()`'s own default 30s startup timeout means it always settles before the 60s outer timeout could abandon it. `ToolHandler.ts`: generalized `#runToolWithTimeout` into `#raceWithTimeout<T>(promise, onTimeout)`, decoupled from `context`/ `forgetBrowser`. `getContext()` is now wrapped in it too, with a new injectable `abandonPendingBrowserAttemptOnTimeout` (defaults to the real `abandonPendingBrowserAttempt`) as its `onTimeout`. Tests: `tests/ToolHandler.test.ts` covers a hung `getContext()` calling `abandonPendingBrowserAttemptOnTimeout` instead of `forgetBrowserOnTimeout` (no resolved context/browser to pull from here). `tests/browser.test.ts` adds two tests against real browsers proving an abandoned `connect()`/`launch()` discards itself instead of installing, and a subsequent call still succeeds normally.
OrKoN
left a comment
There was a problem hiding this comment.
Could you please rebase the PR?
033471a to
2417ec1
Compare
|
Rebased onto current main using the new BrowserManager, see the 2 updated commits. |
2417ec1 to
babf077
Compare
|
Rebased onto current main again, resolving merge conflicts. |
OrKoN
left a comment
There was a problem hiding this comment.
I think the following changes would be required:
- In
src/BrowserManager.ts(BrowserManager.#ensureBrowserLocked), captureconst attempt = this.#browserAttemptbeforeawait this.#mutex.acquire()and verifythis.#browserAttempt === attemptimmediately after acquiring the mutex as well as afterawait this.#initBrowser(). Reading#browserAttemptonly after#mutex.acquire()allows a queuedensureBrowser()call that already timed out while waiting on#mutexto adopt the newly rotated token and launch or connect an abandoned browser once the lock is released. - In
src/index.ts(McpServer.#getContext) andsrc/BrowserManager.ts(BrowserManager.abandonPendingAttempt), ensure that a timeout duringgetContext()also callsforget(browser)ifensureBrowser()has already resolved andMcpContext.from(browser, ...)is what hung on CDP initialization. Currently,abandonPendingAttempt()only invalidates in-flight#initBrowser()calls and leavesthis.#browsercached ifensureBrowser()already returned, causing subsequent tool calls to reuse the same unresponsive browser handle. - In
tests/browser.test.ts(push-based disconnect eviction), remove theas () => voidtype casts ondisconnectedCall.args[1](for example, by callingdisconnectedCall.args[1](undefined)or wiringmockListeneroncreateMockPuppeteerBrowser).AGENTS.mdstrictly forbids using theaskeyword for type casting.
…ead connections proactively Ports the abandon-token / forget() / push-based disconnected-eviction mechanism from this branch's pre-rebase browser.ts onto the new BrowserManager introduced by upstream ChromeDevTools#2787 ("refactor: extract browser in a BrowserManager class"). Not a straight merge: browser.ts was deleted upstream and its module-level state / ensureBrowserConnected / ensureBrowserLaunched functions were replaced by a unified ensureBrowser() serialized behind BrowserManager's own #mutex. Replaces (in spirit, not by cherry-pick) this branch's 2ca8527, c260b4c, and the browser.ts portion of 6d2d4e9: - #browserAttempt generation token + abandonPendingAttempt(), checked in #ensureBrowserLocked() after #initBrowser() returns. Under the new #mutex, two concurrent installs racing each other is now structurally impossible (only one attempt can ever be in flight), so the token's job narrows from "prevent a race between two installs" to "discard a connect()/launch() resolution that arrives after a tool-call timeout already abandoned it" — otherwise a stale connection could be handed to a later, unrelated call. #mutex's scope is left as-is (full ensureBrowser() call) rather than reworked for true parallel recovery; that isn't required to fix the reported bug and would touch two already-reviewed upstream concurrency tests, so it's left as a possible separate follow-up. - forget(candidate) ported directly from forgetBrowser(), including c260b4c's resource-leak fix: it actively closes/disconnects the forgotten browser instead of just dropping the reference, which also settles any CDP call still hung against it. - A push-based `disconnected` listener (#evictIfCurrent), installed in #launch()/#connect(), so a cleanly-detected disconnect is handled proactively instead of only being caught by the next call's lazy `!browser.connected` check. Upstream had neither this nor any forget()-equivalent before this change. Tests: new BrowserManager describe blocks for forget()'s three modes, push-based eviction (including a no-op check for a disconnected event firing on an already-superseded browser), and abandonment in both connect- and launch-mode. The two existing upstream close()-race tests are left untouched and still pass unmodified.
…connection Re-implemented as a fresh diff against upstream's current ToolHandler.ts (post-ChromeDevTools#2659/ChromeDevTools#2787, which predates this branch's whole timeout-wrapping fix), not a literal merge of this branch's prior diff — unrelated upstream divergences (.strict() input schema, `disabled` field, `handle` as a class-field arrow function using `using _guard = ...`) are left as-is. Replaces the ToolHandler.ts portion of this branch's 6d2d4e9, and f67b230 in full: - TOOL_CALL_TIMEOUT_MS, ToolCallTimeoutError, and #raceWithTimeout<T>() ported verbatim. Puppeteer gives no way to cancel a pending call, so a timeout only stops the handler from waiting — the underlying attempt keeps running abandoned, which is exactly why the onTimeout callbacks below exist. - getContext() is wrapped in #raceWithTimeout, calling the injected abandonPendingBrowserAttemptOnTimeout on timeout (see the BrowserManager commit) so a resolution nobody is waiting for anymore doesn't get silently installed for a later caller. - The tool.handler() + response.handle() sequence is wrapped in a single shared budget (matching f67b230's reasoning: several tools' actual CDP calls happen inside response.handle(), not tool.handler(), so both need covering by one timeout or the second phase hangs unprotected after the first one's already accounted for). On timeout, forgetBrowserOnTimeout is called with the resolved context's browser. - src/index.ts: threads BrowserManager's forget()/abandonPendingAttempt() down as bound closures into ToolHandler's two new required constructor params (`forgetBrowserOnTimeout`, `abandonPendingBrowserAttemptOnTimeout`) instead of the old free-function defaults browser.ts used to provide, since BrowserManager is now private instance state owned by McpServer rather than importable module state. #getContext() itself needs no change — it already calls this.#browserManager.ensureBrowser(). This branch's 3d9dd88 (AGENTS.md style fixes: no `!`, no hand-rolled mocks, sinon.assert over Node's assert) has nothing to port forward — this diff was written directly against those rules and upstream's current tests/mocks.ts conventions, so there was nothing to retrofit. Tests: ~23 existing `new ToolHandler(...)` call sites updated for the two new required constructor params (no-op sinon.spy() stand-ins where the test doesn't care about them). Three new regression tests ported from this branch's prior versions: a hung tool.handler() times out and forgets the browser; a hung response.handle() times out even when tool.handler() resolves fast; a hung getContext() times out and abandons the pending attempt without touching forgetBrowserOnTimeout (no resolved browser exists to forget in that case).
babf077 to
8af7351
Compare
The 60s tool-call timeout from #2699 raced the whole tool handler and called BrowserManager.forget() when it fired. forget() closes a launched Chrome, so a valid slow call (wait_for with timeout: 70000, evaluate_script awaiting a long promise, Lighthouse) destroyed the browser and every open page. The timeout existed to detect a transport that died without a close frame. Puppeteer 25.14 provides wsOptions.keepAlive for that case: it pings the socket and terminates it on a missed pong, which rejects the in-flight CDP calls and fires `disconnected`, so #evictIfCurrent() drops the stale handle. - BrowserManager#connect(): set wsOptions.keepAlive and move wsHeaders to wsOptions.headers. - ToolHandler: remove the race around the tool handler and the forgetBrowserOnTimeout parameter. Keep the timeout around getContext() only, where a connect() can hang before keep-alive is active. Fixes #2933
…romeDevTools#3149) Fixes ChromeDevTools#2933 ## Problem ChromeDevTools#2699 raced every tool handler against a 60s timer. On expiry it called `BrowserManager.forget()`, which closes a launched Chrome. The timer could not tell a dead transport from slow valid work. A `wait_for` with `timeout: 70000`, a 65s `evaluate_script`, or a Lighthouse audit destroyed the browser and every open page. `browser.connected` does not detect this case. It flips only on a WebSocket `close` event, and a half-open socket never emits one. ## Fix Detect the dead transport where it happens, and let tool work finish on its own terms. - `BrowserManager#connect()`: set `wsOptions.keepAlive: true` (Puppeteer 25.14). Puppeteer pings every 30s and terminates the socket on a missed pong. That rejects in-flight CDP calls and fires `disconnected`, which the existing `#evictIfCurrent()` handles. Also move `wsHeaders` to `wsOptions.headers`. - `ToolHandler`: remove the race around the tool handler and `response.handle()`, and the `forgetBrowserOnTimeout` parameter. Keep the 60s bound around `getContext()` only, where a `connect()` can hang before keep-alive is active. | Scenario | Before | After | |---|---|---| | Slow valid call (70s `wait_for`, 65s `evaluate_script`) | Fails at 60s, browser closed, pages lost | Finishes; browser kept | | Half-open WS socket mid-call (ChromeDevTools#2699) | Fails at 60s | Fails within ≤60s via keep-alive; next call reconnects | | Renderer hung / dialog open | Fails at 60s, browser closed | Fails at `protocolTimeout` (180s), browser kept (same as 1.10.1) | | `connect()`/`launch()` hangs | Fails at 60s, attempt abandoned | Unchanged | ## Tests - `tests/ToolHandler.test.ts`: removed the two tests that asserted the harmful behavior. Added `does not cut off a slow tool handler on a healthy browser`. Kept the `getContext()` timeout test. - `tests/browser.test.ts`: added `enables WebSocket keep-alive and passes wsHeaders when connecting`. - `npm run test` passes.
🤖 I have created a release *beep* *boop* --- ## [1.11.0](chrome-devtools-mcp-v1.10.1...chrome-devtools-mcp-v1.11.0) (2026-10-15) ### 🎉 Features * add --file-navigations flag to reject file: URL navigations ([#2853](#2853)) ([54cae57](54cae57)) * Add analyze_heapsnapshot_contexts MCP tool ([#2791](#2791)) ([190aeee](190aeee)) * add ignoreCache option to performance_start_trace ([#2931](#2931)) ([3467d40](3467d40)) * add maxNameLength truncation option to compare_heapsnapshots ([#3098](#3098)) ([1e1c53e](1e1c53e)) * Add pagination to compare_heapsnapshots ([#3140](#3140)) ([daebfd1](daebfd1)) * **config:** add ConfigWatcher to watch config file changes ([#3139](#3139)) ([9171f77](9171f77)) * discover the config file in predefined locations ([#2876](#2876)) ([02c0112](02c0112)) * implement ffmpeg-free screencast tools enabled by default ([#3123](#3123)) ([8953ea5](8953ea5)) * reduce StaticText noise in text snapshots ([#2895](#2895)) ([4441325](4441325)) * report pages opened by input actions ([#2679](#2679)) ([28fb230](28fb230)) * resolve config defaults after merging CLI and config file ([#2849](#2849)) ([bdeb70d](bdeb70d)) * return failing audits and DOM nodes inline from lighthouse_audit ([#2930](#2930)) ([241fba5](241fba5)) * skip more redundant data in text snapshots ([#2896](#2896)) ([b2f522c](b2f522c)) * support debugging WebMCP tools in third-party developer tools ([#2900](#2900)) ([0db519f](0db519f)) * support emulating additional CSS media features ([#2929](#2929)) ([69524f0](69524f0)) * support evaluating scripts from local files ([#2606](#2606)) ([9cf47a4](9cf47a4)) * Support truncation in get_heapsnapshot_details ([#3137](#3137)) ([f827e06](f827e06)) * Truncate long names by default to 100 characters ([#2893](#2893)) ([5ddb0a3](5ddb0a3)) ### 🛠️ Fixes * account for scroll offsets in downscaled screenshots ([#2685](#2685)) ([830c693](830c693)) * allow --categoryExtensions when connecting to an existing browser ([#3041](#3041)) ([d250bc5](d250bc5)) * allow stopping the CLI if command fails ([#3088](#3088)) ([77e238e](77e238e)), closes [#2982](#2982) * avoid runtime title fetches ([#2883](#2883)) ([04195d1](04195d1)) * better config support for chrome-devtools CLI ([#2819](#2819)) ([9624e64](9624e64)) * clamp async stack trace separator repeat count ([#3035](#3035)) ([93e06ab](93e06ab)), closes [#3031](#3031) * **cli:** pass positional values starting with `-` through to tools ([#3084](#3084)) ([9de05ae](9de05ae)), closes [#2984](#2984) * **collectors:** ignore transient target errors when subscribing to service workers ([#2888](#2888)) ([551dd6c](551dd6c)) * **daemon:** bound browser shutdown and avoid watchFile timeout on stop ([#2887](#2887)) ([f3db5e7](f3db5e7)) * **daemon:** keep fallback socket in private runtime dir ([#2766](#2766)) ([871a37e](871a37e)) * **daemon:** verify process identity before treating PID file as active ([#3109](#3109)) ([b608bed](b608bed)) * do not close a healthy browser when a tool call outlasts 60s ([#3149](#3149)) ([39c7db1](39c7db1)) * ensure aggregate IDs in heap snapshots are deterministic ([#2923](#2923)) ([e918c47](e918c47)) * escape client-supplied values in McpContext logs and errors ([#2832](#2832)) ([efb0d02](efb0d02)), closes [#2831](#2831) * fail fast on tool calls stuck after a dead browser connection ([#2699](#2699)) ([2a7ef50](2a7ef50)) * harden third-party tool result serialization ([#2892](#2892)) ([4418a7b](4418a7b)) * honor explicit --allowUnrestrictedPaths=false in CLI mode ([#3040](#3040)) ([61fc362](61fc362)) * include errors in slim responses ([#3085](#3085)) ([ee38097](ee38097)) * **input:** reject multiple file paths on single-file input in upload_file ([#2995](#2995)) ([#3135](#3135)) ([e650843](e650843)) * list fresh page titles ([#3103](#3103)) ([e717082](e717082)) * **memory:** reject contradictory pagination options in take_heapsnapshot ([#3002](#3002)) ([#3131](#3131)) ([508126c](508126c)) * **network:** enforce URL policy across redirects ([#2767](#2767)) ([274cd4c](274cd4c)) * pass categoryExtensions to the target filter when connecting ([#3047](#3047)) ([4e90238](4e90238)) * **performance:** report an error when performance_stop_trace is called with no active trace ([#3001](#3001)) ([#3126](#3126)) ([e170384](e170384)) * preserve HeapSnapshotManager across browser reconnects ([#3025](#3025)) ([64388c6](64388c6)) * propagate failed responseFilePath write error instead of reporting body unavailable ([#2957](#2957)) ([#3119](#3119)) ([3cee3bd](3cee3bd)) * **pwa:** wait for initial navigation on launch and retry transient install error ([#2889](#2889)) ([63010cb](63010cb)) * record screencast at the page's device pixel size ([#3155](#3155)) ([62e2aa4](62e2aa4)) * reject --blockedUrlPattern/--allowedUrlPattern hostname regexp groups ([#2796](#2796)) ([ae0aaef](ae0aaef)) * reject JSON arrays as 3p and WebMCP tool params ([#2785](#2785)) ([c14e616](c14e616)) * reject named groups in URL patterns ([#2857](#2857)) ([5b2c6f9](5b2c6f9)) * reject non-positive --viewport dimensions ([#2781](#2781)) ([0ef528a](0ef528a)) * reject non-positive resize_page dimensions ([#2784](#2784)) ([6ab6d35](6ab6d35)) * reject unrestricted paths with an explicit workspace ([#2858](#2858)) ([45c1c6c](45c1c6c)) * report unknown page id before last-page guard in close_page ([#3042](#3042)) ([bdc7e24](bdc7e24)) * round lighthouse category scores and show unscored categories as n/a ([#2924](#2924)) ([7007680](7007680)), closes [#2915](#2915) [#2916](#2916) * set empty filePath to undefined instead of empty string ([#2836](#2836)) ([adfc1ff](adfc1ff)), closes [#2825](#2825) * surface WebMCP tool exceptions in execute_webmcp_tool ([#3107](#3107)) ([d80d22e](d80d22e)), closes [#2975](#2975) * url pattern partial ipv4 ([#2859](#2859)) ([c87d190](c87d190)) ### 📄 Documentation * clarify Antigravity MCP setup for VS Code extension ([#2855](#2855)) ([12e13ca](12e13ca)) * clarify scope of --no-javascript-evaluation ([#3100](#3100)) ([0c67cd5](0c67cd5)) * correct link to configuration ([#3086](#3086)) ([bbb1e36](bbb1e36)) * document trusted host environment in SECURITY.md ([#3125](#3125)) ([1352207](1352207)) * fix inaccurate examples in skills and CLI docs ([#2922](#2922)) ([ec372b0](ec372b0)), closes [#2906](#2906) [#2907](#2907) [#2908](#2908) [#2910](#2910) [#2912](#2912) [#2913](#2913) [#2918](#2918) [#2919](#2919) [#2920](#2920) [#2921](#2921) * fix some reported issues ([#3099](#3099)) ([d5d2f08](d5d2f08)) * include serviceWorkerId parameter for evaluate_script ([#3015](#3015)) ([#3129](#3129)) ([0623434](0623434)) * mention heapsnapshot being cached between runs ([#3045](#3045)) ([f08dbe1](f08dbe1)), closes [#2976](#2976) * **skills:** remove invalid outputDir flag from lighthouse_audit calls ([#3013](#3013)) ([#3130](#3130)) ([7754226](7754226)) * update documentation and SKILL for get_css_styles tool ([#2824](#2824)) ([3c12a91](3c12a91)) ### ⚡ Performance * **cli:** re-use MCPServer.from helpers for daemon ([#2804](#2804)) ([89eb3d5](89eb3d5)) * Load heap snapshots in parallel in compare_heapsnapshots ([#3023](#3023)) ([20c1391](20c1391)) ### 🏗️ Refactor * centralize config defaults and conflict checks ([#2753](#2753)) ([a739ba8](a739ba8)) * create all tools and register per slim mode ([#2874](#2874)) ([99847a7](99847a7)) * enable categories by default ([#2811](#2811)) ([e33ee48](e33ee48)) * extract CLI examples and conflict list in mcp-options ([#2848](#2848)) ([45000d9](45000d9)) * extract config parsing logic in a class ([#2861](#2861)) ([e4168d0](e4168d0)) * extract worker logic into McpWorker ([#2800](#2800)) ([77165c6](77165c6)) * group Puppeteer and tool options ([#2875](#2875)) ([699c4d5](699c4d5)) * lazily initialize McpPage from Target and enumerate targets in McpContext ([#2812](#2812)) ([545cbe3](545cbe3)) * use default Error for toolSchema ([#2822](#2822)) ([8b2768d](8b2768d)) --- 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]>
Root cause: when the debugged browser's CDP transport dies mid-call — silently, without ever firing a
close/error/disconnectedevent (as opposed to a clean disconnect) — the in-flight tool call just hangs forever waiting on a response that will never come. BecauseToolHandlerserializes every tool call behind a single sharedMutex, that one stuck call blocks all subsequent tool calls too, effectively taking the whole MCP server down until someone manually reconnects via/mcp.Observed when an Android app being debugged over
chrome-devtools-mcpwas reinstalled/relaunched mid-session, the MCP server's tools went completely unavailable, even though the underlying CDP endpoint (http://127.0.0.1:9222/json) stayed reachable the whole time. This wasn't a startup/connection-time failure, which the existing "next-call self-heal" logic already handles fine — it was a hang mid-call, so there was never a clean "next call" for that self-heal to run on.browser.ts: exportforgetBrowser()and attach adisconnectedlistener after every successful connect/launch, so a browser Puppeteer does detect as closed is dropped from the module cache immediately rather than relying solely on the next call'sbrowser?.connectedcheck.ToolHandler.ts: bound each tool handler invocation with a 60s timeout. On timeout, forget the cached browser handle and fail with a clear error instead of hanging until the client's own timeout gives up on the whole server. The next tool call then reconnects via the existingensureBrowserConnected/#getContextself-heal path instead of reusing a handle that still looks connected. The forget call is now injectable via an optional constructor parameter (defaulting to the realforgetBrowser), so the timeout path can be unit tested without stubbing an ES module.tests/ToolHandler.test.ts: cover the timeout path directly — a tool handler that never resolves triggers the 60s timeout,forgetBrowseris called with the current browser, and a normal (non-timeout) handler rejection does not trigger it.tests/browser.test.ts: cover the disconnected-listener path against a real launched browser — a cleandisconnect()is forgotten automatically so the nextensureBrowserConnected()reconnects instead of reusing the dead handle, andforgetBrowser()only clears the cache on an exact reference match.Deliberately scoped to fail-fast + rely on the existing next-call self-heal, not automatic retry-and-replay of the timed-out call (a larger change to discuss with whoever verifies this against the real device). A full Android reproduction is out of scope for this change; verified here via the targeted unit tests above.