Repository navigation
fix(browser): retry only transient connection failures in connect - #3557
Merged
wolfib merged 1 commit intoDec 1, 2026
Merged
Conversation
cheyoung1983-sudo
added a commit
to cheyoung1983-sudo/chrome-devtools-mcp
that referenced
this pull request
Nov 20, 2026
Refactor BrowserManager connect retry logic to inspect error.cause chains, AggregateError.errors, and ws ErrorEvent objects for leaf transient error codes (ECONNREFUSED, ECONNRESET, UND_ERR_SOCKET, EPIPE, EAI_AGAIN, ETIMEDOUT). Permanent errors fail immediately without retry. Log statements output only attempt count and error codes to prevent credential leaks. Fixes ChromeDevTools#3374 Refs ChromeDevTools#3375, ChromeDevTools#3557
cheyoung1983-sudo
force-pushed
the
fix/connect-retry-transient
branch
from
November 20, 2026 03:56
89100b0 to
a35f5d5
Compare
wolfib
requested changes
Nov 26, 2026
wolfib
left a comment
Contributor
There was a problem hiding this comment.
I would suggest to keep the retry helper private in BrowserManager.ts, follow the leaf-code extractor from #3375 without error instanceof TypeError or substring arrays, and pass an abort check from #ensureBrowserLocked() into #connect(). This removes all 5 test-only exports, fixes --browserUrl retries, prevents retries after close() or abandonPendingAttempt(), and shrinks the diff.
Retry puppeteer.connect() up to 3 times (250ms, then 500ms backoff) when the error's leaf code is a transient transport code (ECONNREFUSED, ECONNRESET, EPIPE, EAI_AGAIN, UND_ERR_SOCKET). The code is read from the root of the cause chain, from ws ErrorEvent.error, and from every entry of an AggregateError, so --browserUrl fetch failures and ws errors are classified by their root cause and permanent errors (invalid URL, 403 consent denial, EACCES/ENOENT) fail immediately. #ensureBrowserLocked() passes an abort check into #connect() so retries stop after close() or abandonPendingAttempt(). Fixes ChromeDevTools#3374
cheyoung1983-sudo
force-pushed
the
fix/connect-retry-transient
branch
from
November 29, 2026 13:49
a35f5d5 to
1bc08c3
Compare
timothybrush
pushed a commit
to timothybrush/chrome-devtools-mcp
that referenced
this pull request
Dec 1, 2026
…vTools#3649) ## Summary When connecting over WebSocket with `--wsHeaders` and logging enabled (`--logFile` or `NODE_DEBUG=mcp:log`), `BrowserManager.#connect()` stores credentials under `connectOptions.wsOptions.headers` before logging `JSON.stringify(redactConnectOptionsForLogging(connectOptions))`. `redactConnectOptionsForLogging()` previously only redacted top-level `options.headers`, leaving `options.wsOptions.headers` unredacted in logs (while ChromeDevTools#3149 had already moved connection headers into `wsOptions.headers` before ChromeDevTools#2901 landed). ## Changes - **`src/utils/logger.ts`**: - Extract `redactHeadersForLogging()` and use it in `redactConnectOptionsForLogging()` for both `options.headers` and `options.wsOptions?.headers`, preserving sibling `wsOptions` fields (such as `keepAlive`) without mutating input objects. - Clear `logFileStream` in `flushLogs()` when closing the active log stream so subsequent `logger?.()` calls do not write to an ended stream. - **`tests/utils/logger.test.ts`**: - Add unit tests covering `wsOptions.headers` redaction, unchanged `wsOptions` when `headers` is `undefined`, and `flushLogs()` stream detachment. - **`tests/browser.test.ts`**: - Extend `preserves WebSocket connection credentials for Puppeteer while redacting logs` to capture log output via `saveLogsToFile()`/`flushLogs()` and assert header values and URL credentials do not reach disk. > Note: Production changes are isolated to `src/utils/logger.ts`. Compared with open PR ChromeDevTools#3557 (which modifies `src/BrowserManager.ts` and unrelated lines in `tests/browser.test.ts`), the logic is independent and touches only a disjoint test block in `tests/browser.test.ts` (ready to rebase cleanly if ChromeDevTools#3557 merges first). ## Testing - Added and verified `tests/utils/logger.test.ts` unit cases (all 19 cases passing with compiled TS + `node --test`, and failing as expected against unpatched `main`). - Verified formatting with Prettier (`npm run format` rules) and lint rules with ESLint; `tests/browser.test.ts` full test run will execute on CI.
timothybrush
pushed a commit
to timothybrush/chrome-devtools-mcp
that referenced
this pull request
Dec 1, 2026
…tests (ChromeDevTools#3685) Follow-up to ChromeDevTools#3557 addressing minor test issues in `tests/browser.test.ts`: - Replace the `as Error` type cast with `instanceof Error` assertions. - Use `sinon.useFakeTimers({toFake: ['setTimeout', 'clearTimeout']})` so connect retry tests run without real delays and verify the 250ms and 500ms backoff schedule. - Trigger `close()` and `abandonPendingAttempt()` during the backoff timer (verified via `clock.countTimers()`) instead of before backoff starts, and await `manager.close()`.
timothybrush
pushed a commit
to timothybrush/chrome-devtools-mcp
that referenced
this pull request
Dec 2, 2026
🤖 I have created a release *beep* *boop* --- ## [1.15.0](ChromeDevTools/chrome-devtools-mcp@chrome-devtools-mcp-v1.14.0...chrome-devtools-mcp-v1.15.0) (2026-12-02) ### 🎉 Features * add agents plugin marketplace ([ChromeDevTools#3534](ChromeDevTools#3534)) ([aa8b35d](ChromeDevTools@aa8b35d)) * add Codex plugin manifest ([ChromeDevTools#3588](ChromeDevTools#3588)) ([ad15052](ChromeDevTools@ad15052)) * **cli:** document --sessionId and add CHROME_DEVTOOLS_SESSION_ID ([ChromeDevTools#3562](ChromeDevTools#3562)) ([bd1bbbb](ChromeDevTools@bd1bbbb)) * **cli:** stop the CLI daemon after --idleTimeout ([ChromeDevTools#3620](ChromeDevTools#3620)) ([d0d47a3](ChromeDevTools@d0d47a3)), closes [ChromeDevTools#3427](ChromeDevTools#3427) * close or disconnect idle browser after --idleTimeout ([ChromeDevTools#3619](ChromeDevTools#3619)) ([cd426c2](ChromeDevTools@cd426c2)), closes [ChromeDevTools#3427](ChromeDevTools#3427) * **comments:** add includeTransmitted to get_devtools_comments ([ChromeDevTools#3644](ChromeDevTools#3644)) ([81dc479](ChromeDevTools@81dc479)) * limit node IDs in duplicate string summaries ([ChromeDevTools#3546](ChromeDevTools#3546)) ([5b17907](ChromeDevTools@5b17907)) * **tests:** generate and load GN tests.txt manifest in test runner ([ChromeDevTools#3677](ChromeDevTools#3677)) ([ced63d4](ChromeDevTools@ced63d4)) * **tests:** match CLI paths and globs against tests.txt manifest ([ChromeDevTools#3681](ChromeDevTools#3681)) ([81e89f6](ChromeDevTools@81e89f6)) * **tests:** support --isolated-script-test-filter in test runner ([ChromeDevTools#3679](ChromeDevTools#3679)) ([8c6dcf8](ChromeDevTools@8c6dcf8)) * **tests:** support GTEST_SHARD_INDEX and GTEST_TOTAL_SHARDS in test runner ([ChromeDevTools#3678](ChromeDevTools#3678)) ([60ccf0b](ChromeDevTools@60ccf0b)) ### 🛠️ Fixes * avoid partial percent escapes when truncating URLs ([ChromeDevTools#3630](ChromeDevTools#3630)) ([63a02cd](ChromeDevTools@63a02cd)) * **browser:** retry only transient connection failures in connect ([ChromeDevTools#3557](ChromeDevTools#3557)) ([c4d369d](ChromeDevTools@c4d369d)) * **cli:** exit non-zero when an MCP tool returns isError ([ChromeDevTools#3661](ChromeDevTools#3661)) ([a8b60be](ChromeDevTools@a8b60be)) * **cli:** harden literal arg shielding for non-tool and unknown commands ([ChromeDevTools#3625](ChromeDevTools#3625)) ([3c40359](ChromeDevTools@3c40359)) * **cli:** redact sensitive daemon startup args in status output ([ChromeDevTools#3623](ChromeDevTools#3623)) ([41a236c](ChromeDevTools@41a236c)) * **cli:** reject empty --workspace or --filesystem-root on start ([ChromeDevTools#3624](ChromeDevTools#3624)) ([c0ec9fe](ChromeDevTools@c0ec9fe)) * **cli:** report a daemon that exits during startup instead of timing out ([ChromeDevTools#3381](ChromeDevTools#3381)) ([2471010](ChromeDevTools@2471010)), closes [ChromeDevTools#3378](ChromeDevTools#3378) * **comments:** tell agents to stop when DevTools comments are unsupported ([ChromeDevTools#3616](ChromeDevTools#3616)) ([d8d8e58](ChromeDevTools@d8d8e58)) * **console:** dispose the arguments of dropped console messages ([ChromeDevTools#3409](ChromeDevTools#3409)) ([691244a](ChromeDevTools@691244a)) * **console:** do not group consecutive messages that log different objects ([ChromeDevTools#3642](ChromeDevTools#3642)) ([aacf611](ChromeDevTools@aacf611)) * **daemon:** check Windows named pipe before spawning PowerShell for PID verification ([ChromeDevTools#3647](ChromeDevTools#3647)) ([609c0dd](ChromeDevTools@609c0dd)) * **daemon:** validate runtime directory, PID file, and socket on CLI client ([ChromeDevTools#3637](ChromeDevTools#3637)) ([c085bb3](ChromeDevTools@c085bb3)) * distinguish same-document navigations from page loads ([ChromeDevTools#3410](ChromeDevTools#3410)) ([2732e75](ChromeDevTools@2732e75)) * ignore targets with a subtype (such as prerender targets) ([ChromeDevTools#3675](ChromeDevTools#3675)) ([b6f545f](ChromeDevTools@b6f545f)) * match preflight and prefetch network mocks ([ChromeDevTools#3608](ChromeDevTools#3608)) ([7fcebb2](ChromeDevTools@7fcebb2)), closes [ChromeDevTools#3601](ChromeDevTools#3601) * **memory:** preserve heap snapshot sortBy order in responses ([ChromeDevTools#3612](ChromeDevTools#3612)) ([a613851](ChromeDevTools@a613851)) * **skills:** check viewport intersection in the LCP image audit ([ChromeDevTools#3632](ChromeDevTools#3632)) ([0063b7c](ChromeDevTools@0063b7c)) * **skills:** use native label associations in the accessibility check ([ChromeDevTools#3617](ChromeDevTools#3617)) ([8c43179](ChromeDevTools@8c43179)) * **skills:** watch for DevTools comments by default in inspect-in-devtools ([ChromeDevTools#3638](ChromeDevTools#3638)) ([78f6a5b](ChromeDevTools@78f6a5b)) * **telemetry:** handle asynchronous stdin errors in WatchdogClient ([ChromeDevTools#3651](ChromeDevTools#3651)) ([b4a7e6b](ChromeDevTools@b4a7e6b)) * **telemetry:** log tool invocation success as false when response has an error ([ChromeDevTools#3674](ChromeDevTools#3674)) ([4025927](ChromeDevTools@4025927)) * use `npx chrome-devtools-mcp` in --help for local node_modules ([ChromeDevTools#3672](ChromeDevTools#3672)) ([a72f527](ChromeDevTools@a72f527)) * use binary name in --help when not invoked via npx ([ChromeDevTools#3628](ChromeDevTools#3628)) ([94f7f1a](ChromeDevTools@94f7f1a)) * wait for all running queues in TaskRunner.pause() ([ChromeDevTools#3650](ChromeDevTools#3650)) ([6270b82](ChromeDevTools@6270b82)) ### 📄 Documentation * document how to test Chrome Built-in AI ([ChromeDevTools#3636](ChromeDevTools#3636)) ([9a83b1b](ChromeDevTools@9a83b1b)) * **skill:** split chrome-devtools-cli SKILL.md into core and references ([ChromeDevTools#3660](ChromeDevTools#3660)) ([8760ae0](ChromeDevTools@8760ae0)) ### ⚡ Performance * load issue descriptions on the first tool call ([ChromeDevTools#3573](ChromeDevTools#3573)) ([979e8a4](ChromeDevTools@979e8a4)) ### 🏗️ Refactor * **tests:** remove manual .only() pre-scan in run-tests.ts ([ChromeDevTools#3683](ChromeDevTools#3683)) ([efedc27](ChromeDevTools@efedc27)) * **tests:** wrap run-tests.ts entrypoint in main() guarded by import.meta.main ([ChromeDevTools#3676](ChromeDevTools#3676)) ([fd87660](ChromeDevTools@fd87660)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
copybara-service Bot
pushed a commit
to ChromeDevTools/devtools-frontend
that referenced
this pull request
Dec 3, 2026
🤖 I have created a release *beep* *boop* --- ## [1.15.0](ChromeDevTools/chrome-devtools-mcp@chrome-devtools-mcp-v1.14.0...chrome-devtools-mcp-v1.15.0) (2026-12-02) ### 🎉 Features * add agents plugin marketplace ([#3534](ChromeDevTools/chrome-devtools-mcp#3534)) ([96f6322](ChromeDevTools/chrome-devtools-mcp@96f6322)) * add Codex plugin manifest ([#3588](ChromeDevTools/chrome-devtools-mcp#3588)) ([ea1f814](ChromeDevTools/chrome-devtools-mcp@ea1f814)) * **cli:** document --sessionId and add CHROME_DEVTOOLS_SESSION_ID ([#3562](ChromeDevTools/chrome-devtools-mcp#3562)) ([720a6a2](ChromeDevTools/chrome-devtools-mcp@720a6a2)) * **cli:** stop the CLI daemon after --idleTimeout ([#3620](ChromeDevTools/chrome-devtools-mcp#3620)) ([5400332](ChromeDevTools/chrome-devtools-mcp@5400332)), closes [#3427](ChromeDevTools/chrome-devtools-mcp#3427) * close or disconnect idle browser after --idleTimeout ([#3619](ChromeDevTools/chrome-devtools-mcp#3619)) ([dc3928c](ChromeDevTools/chrome-devtools-mcp@dc3928c)), closes [#3427](ChromeDevTools/chrome-devtools-mcp#3427) * **comments:** add includeTransmitted to get_devtools_comments ([#3644](ChromeDevTools/chrome-devtools-mcp#3644)) ([9246840](ChromeDevTools/chrome-devtools-mcp@9246840)) * limit node IDs in duplicate string summaries ([#3546](ChromeDevTools/chrome-devtools-mcp#3546)) ([043be4d](ChromeDevTools/chrome-devtools-mcp@043be4d)) * **tests:** generate and load GN tests.txt manifest in test runner ([#3677](ChromeDevTools/chrome-devtools-mcp#3677)) ([a5ff683](ChromeDevTools/chrome-devtools-mcp@a5ff683)) * **tests:** match CLI paths and globs against tests.txt manifest ([#3681](ChromeDevTools/chrome-devtools-mcp#3681)) ([49cc8c0](ChromeDevTools/chrome-devtools-mcp@49cc8c0)) * **tests:** support --isolated-script-test-filter in test runner ([#3679](ChromeDevTools/chrome-devtools-mcp#3679)) ([2306f37](ChromeDevTools/chrome-devtools-mcp@2306f37)) * **tests:** support GTEST_SHARD_INDEX and GTEST_TOTAL_SHARDS in test runner ([#3678](ChromeDevTools/chrome-devtools-mcp#3678)) ([0892ed4](ChromeDevTools/chrome-devtools-mcp@0892ed4)) ### 🛠️ Fixes * avoid partial percent escapes when truncating URLs ([#3630](ChromeDevTools/chrome-devtools-mcp#3630)) ([817c37a](ChromeDevTools/chrome-devtools-mcp@817c37a)) * **browser:** retry only transient connection failures in connect ([#3557](ChromeDevTools/chrome-devtools-mcp#3557)) ([1a02659](ChromeDevTools/chrome-devtools-mcp@1a02659)) * **cli:** exit non-zero when an MCP tool returns isError ([#3661](ChromeDevTools/chrome-devtools-mcp#3661)) ([2b28369](ChromeDevTools/chrome-devtools-mcp@2b28369)) * **cli:** harden literal arg shielding for non-tool and unknown commands ([#3625](ChromeDevTools/chrome-devtools-mcp#3625)) ([de581d0](ChromeDevTools/chrome-devtools-mcp@de581d0)) * **cli:** redact sensitive daemon startup args in status output ([#3623](ChromeDevTools/chrome-devtools-mcp#3623)) ([b018e8a](ChromeDevTools/chrome-devtools-mcp@b018e8a)) * **cli:** reject empty --workspace or --filesystem-root on start ([#3624](ChromeDevTools/chrome-devtools-mcp#3624)) ([2045a94](ChromeDevTools/chrome-devtools-mcp@2045a94)) * **cli:** report a daemon that exits during startup instead of timing out ([#3381](ChromeDevTools/chrome-devtools-mcp#3381)) ([945bcab](ChromeDevTools/chrome-devtools-mcp@945bcab)), closes [#3378](ChromeDevTools/chrome-devtools-mcp#3378) * **comments:** tell agents to stop when DevTools comments are unsupported ([#3616](ChromeDevTools/chrome-devtools-mcp#3616)) ([6606ad2](ChromeDevTools/chrome-devtools-mcp@6606ad2)) * **console:** dispose the arguments of dropped console messages ([#3409](ChromeDevTools/chrome-devtools-mcp#3409)) ([5e080d1](ChromeDevTools/chrome-devtools-mcp@5e080d1)) * **console:** do not group consecutive messages that log different objects ([#3642](ChromeDevTools/chrome-devtools-mcp#3642)) ([d8a8e17](ChromeDevTools/chrome-devtools-mcp@d8a8e17)) * **daemon:** check Windows named pipe before spawning PowerShell for PID verification ([#3647](ChromeDevTools/chrome-devtools-mcp#3647)) ([86dda86](ChromeDevTools/chrome-devtools-mcp@86dda86)) * **daemon:** validate runtime directory, PID file, and socket on CLI client ([#3637](ChromeDevTools/chrome-devtools-mcp#3637)) ([eb6441b](ChromeDevTools/chrome-devtools-mcp@eb6441b)) * distinguish same-document navigations from page loads ([#3410](ChromeDevTools/chrome-devtools-mcp#3410)) ([9bf59e4](ChromeDevTools/chrome-devtools-mcp@9bf59e4)) * ignore targets with a subtype (such as prerender targets) ([#3675](ChromeDevTools/chrome-devtools-mcp#3675)) ([43370eb](ChromeDevTools/chrome-devtools-mcp@43370eb)) * match preflight and prefetch network mocks ([#3608](ChromeDevTools/chrome-devtools-mcp#3608)) ([5b35a1b](ChromeDevTools/chrome-devtools-mcp@5b35a1b)), closes [#3601](ChromeDevTools/chrome-devtools-mcp#3601) * **memory:** preserve heap snapshot sortBy order in responses ([#3612](ChromeDevTools/chrome-devtools-mcp#3612)) ([de86004](ChromeDevTools/chrome-devtools-mcp@de86004)) * **skills:** check viewport intersection in the LCP image audit ([#3632](ChromeDevTools/chrome-devtools-mcp#3632)) ([51c10e3](ChromeDevTools/chrome-devtools-mcp@51c10e3)) * **skills:** use native label associations in the accessibility check ([#3617](ChromeDevTools/chrome-devtools-mcp#3617)) ([ff5ab1d](ChromeDevTools/chrome-devtools-mcp@ff5ab1d)) * **skills:** watch for DevTools comments by default in inspect-in-devtools ([#3638](ChromeDevTools/chrome-devtools-mcp#3638)) ([167c184](ChromeDevTools/chrome-devtools-mcp@167c184)) * **telemetry:** handle asynchronous stdin errors in WatchdogClient ([#3651](ChromeDevTools/chrome-devtools-mcp#3651)) ([1e324e2](ChromeDevTools/chrome-devtools-mcp@1e324e2)) * **telemetry:** log tool invocation success as false when response has an error ([#3674](ChromeDevTools/chrome-devtools-mcp#3674)) ([67e46c1](ChromeDevTools/chrome-devtools-mcp@67e46c1)) * use `npx chrome-devtools-mcp` in --help for local node_modules ([#3672](ChromeDevTools/chrome-devtools-mcp#3672)) ([17a3025](ChromeDevTools/chrome-devtools-mcp@17a3025)) * use binary name in --help when not invoked via npx ([#3628](ChromeDevTools/chrome-devtools-mcp#3628)) ([e6d72ec](ChromeDevTools/chrome-devtools-mcp@e6d72ec)) * wait for all running queues in TaskRunner.pause() ([#3650](ChromeDevTools/chrome-devtools-mcp#3650)) ([0b17900](ChromeDevTools/chrome-devtools-mcp@0b17900)) ### 📄 Documentation * document how to test Chrome Built-in AI ([#3636](ChromeDevTools/chrome-devtools-mcp#3636)) ([82945bf](ChromeDevTools/chrome-devtools-mcp@82945bf)) * **skill:** split chrome-devtools-cli SKILL.md into core and references ([#3660](ChromeDevTools/chrome-devtools-mcp#3660)) ([bec84ba](ChromeDevTools/chrome-devtools-mcp@bec84ba)) ### ⚡ Performance * load issue descriptions on the first tool call ([#3573](ChromeDevTools/chrome-devtools-mcp#3573)) ([7f7b110](ChromeDevTools/chrome-devtools-mcp@7f7b110)) ### 🏗️ Refactor * **tests:** remove manual .only() pre-scan in run-tests.ts ([#3683](ChromeDevTools/chrome-devtools-mcp#3683)) ([b964dda](ChromeDevTools/chrome-devtools-mcp@b964dda)) * **tests:** wrap run-tests.ts entrypoint in main() guarded by import.meta.main ([#3676](ChromeDevTools/chrome-devtools-mcp#3676)) ([e2dfdf3](ChromeDevTools/chrome-devtools-mcp@e2dfdf3)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Retry only transient connection failures in
BrowserManagerwhen callingpuppeteer.connect. Fixes #3374.Reworked per @wolfib's review: rebased onto current
mainas a single commit, with the unrelatedPageCollector/browser.tschanges dropped.Behavior
BrowserManager.ts(the one suggested on fix(browser): retry only transient connection failures in connect #3375) reads the error's code from the root of thecausechain, fromwsErrorEvent.error, and from every entry of anAggregateError. It retries onlyECONNREFUSED,ECONNRESET,EPIPE,EAI_AGAIN, andUND_ERR_SOCKET. There is noinstanceof TypeErrorcheck and no substring list, so--browserUrlfetch failures (TypeError('fetch failed', {cause})) are classified by their root cause.EACCES), and mixedAggregateErrors.#ensureBrowserLocked()passes an abort check into#connect(), so retries stop afterclose()orabandonPendingAttempt().Test plan
tests/browser.test.ts, run throughBrowserManager.ensureBrowser():--browserUrlTypeErrorfetch failure then success;wsErrorEventwrapping an all-transientAggregateErrorthen success; exhausting 3 attempts; no retry for invalid URL, 403,EACCESroot cause, or a mixed aggregate; no further attempts afterclose()orabandonPendingAttempt()during backoff.npm run sync,npm test,npm run check-format, andnpm run gen(no diff) all pass.