Repository navigation
refactor: create BrowserManager without the browser bundle - #3563
Merged
Lightning00Blade merged 1 commit intoNov 23, 2026
Merged
Lightning00Blade merged 1 commit into
Lightning00Blade merged 1 commit into
Conversation
yulunz
force-pushed
the
refactor/lazy-browser-manager
branch
from
November 19, 2026 22:01
8cd55da to
5f4b17c
Compare
yulunz
changed the base branch from
chore/remove-browser-imports-test
to
refactor/move-mutex-to-light-bundle
November 19, 2026 22:06
OrKoN
approved these changes
Nov 20, 2026
Lightning00Blade
force-pushed
the
refactor/lazy-browser-manager
branch
from
November 23, 2026 12:36
5f4b17c to
36cd8f7
Compare
Lightning00Blade
enabled stacked auto-merge
November 23, 2026 12:40
github-merge-queue
Bot
removed this pull request from the merge queue because a pull request earlier in the stack was removed
Nov 23, 2026
BrowserManager.ts now imports only types from third_party/browser.js and gets Puppeteer from loadBrowser() right before it launches or connects. puppeteer.setFollowSymlinks(false) moves from the top of src/index.ts to that point, so every launch and connect still disables following symlinks. Refs #3427
Lightning00Blade
force-pushed
the
refactor/lazy-browser-manager
branch
from
November 23, 2026 13:23
36cd8f7 to
8a5b4ed
Compare
OrKoN
pushed a commit
to JasonOA888/chrome-devtools-mcp
that referenced
this pull request
Nov 23, 2026
…evTools#3566) Refs ChromeDevTools#3427 Stacked on ChromeDevTools#3561. Splits the `Mutex` bundle move out of ChromeDevTools#3563 so `BrowserManager` can drop value imports from `third_party/browser.js` in its own PR. Behavior doesn't change. ## What moved - **`Mutex`**: - Now re-exported from the light `src/third_party/index.ts` by its direct path (`puppeteer-core/internal/util/Mutex.js`) instead of `src/third_party/browser.ts`. `BrowserManager` uses `Mutex` in a field initializer. - `src/BrowserManager.ts`, `src/McpContext.ts`, and `src/NetworkOverrideManager.ts` import `Mutex` from `./third_party/index.js`, so it's exported in one place. ## Modules now in both bundles New with this PR, compared from the two metafiles (debug build): | Module | Size in index.js | Why it's safe | |---|---|---| | `puppeteer-core/…/util/Mutex.js` | 0.8 KiB | Each user creates its own `Mutex` instance. Nothing checks `instanceof Mutex`, and no instance is passed into Puppeteer. | | `puppeteer-core/…/util/Deferred.js` | 2.0 KiB | Imported by `Mutex.js`. `Mutex` only calls `Deferred.create()` without a timeout, so this copy never creates a `TimeoutError`. `Deferred` isn't exported from `index.ts`. | | `puppeteer-core/…/common/Errors.js` (tree-shaken part) | 0.3 KiB | Imported by `Deferred.js` for its timeout path, which `Mutex` doesn't use. `TimeoutError` is still exported only from `browser.ts`, so `instanceof` checks in tools keep using Puppeteer's class. | Already in both bundles from earlier PRs: `disposable.js`, `PredefinedNetworkConditions.js`, `StringUtilities.ts`, `Debouncer.ts`. ## Test plan - `npm run test tests/browser.test.ts tests/McpContext.test.ts tests/NetworkOverrideManager.test.ts tests/network_overrides.test.ts tests/third_party_notices.test.ts`. - `npm run format` and `npm run build`.
OrKoN
pushed a commit
to JasonOA888/chrome-devtools-mcp
that referenced
this pull request
Nov 23, 2026
…vTools#3564) Refs ChromeDevTools#3427 Lazy loading: server startup part b, stacked on ChromeDevTools#3563. Behavior doesn't change. ## What changed - **`src/processors/HeapSnapshotManager.ts`**: imports `DevTools` only as a type. `DevTools` values are used in three methods, all of them async, so no synchronous code needed changing: - `getAggregates()` and `getNodesById()` create a `NodeFilter`. They call `await loadBrowser()` after `getSnapshot()`, which has already loaded the bundle by then, so it returns the cached module. - `#loadSnapshot()` creates the `HeapSnapshotWorkerProxy`, reads `Console.instance()` and creates a `NodeFilter`. `await loadBrowser()` is now the first step inside its `try`: - A failed load still removes the cached promise from `#snapshots` (the existing cleanup). - `workerProxy` is declared before the `try` and disposed with `?.`, because it doesn't exist yet if loading fails. - Before, the worker was created before the `try`, so an error while creating it skipped that cleanup. Now it runs in all cases. - **ESLint:** `src/processors/HeapSnapshotManager.ts` is added to the block that rejects value imports from `browser.js`. ## Modules now in both bundles None new. ## What still loads browser.js at startup `processors/HeapSnapshotManager.js` no longer reaches `browser.js`: ``` bin/chrome-devtools-mcp-main.js -> index.js index.js -> McpContext.js, ToolHandler.js ToolHandler.js -> McpResponse.js, SlimMcpResponse.js daemon/daemon.js -> index.js ``` `McpContext` still reaches `browser.js` (part d), and so does `ToolHandler` through `McpResponse` (part c). ## Test plan - `npm run test tests/processors/HeapSnapshotManager.test.ts tests/tools/memory.test.ts tests/formatters/HeapSnapshotFormatter.test.ts tests/McpServer.test.ts`. The existing tests cover snapshot loading, aggregates, `getNodesById` and a failed load. - No new test: the only new path is `loadBrowser()` rejecting, and it can't happen in a test process that has already loaded the bundle. - `npm run format`. Full `npm run test` on the top of parts a–c.
mijanurecon452-tech
pushed a commit
to mijanurecon452-tech/chrome-devtools-mcp
that referenced
this pull request
Nov 24, 2026
🤖 I have created a release *beep* *boop* --- ## [1.14.0](ChromeDevTools/chrome-devtools-mcp@chrome-devtools-mcp-v1.13.0...chrome-devtools-mcp-v1.14.0) (2026-11-24) ### 🎉 Features * add --backgroundNewPages to keep new_page tabs in the background ([ChromeDevTools#3539](ChromeDevTools#3539)) ([7a39d6d](ChromeDevTools@7a39d6d)) * add abort and allow-origin network mocks ([ChromeDevTools#3421](ChromeDevTools#3421)) ([eb4b53d](ChromeDevTools@eb4b53d)) * add inspect-in-devtools skill and claude plugin command ([ChromeDevTools#2696](ChromeDevTools#2696)) ([aa977a6](ChromeDevTools@aa977a6)) * add network requests from service workers ([ChromeDevTools#3554](ChromeDevTools#3554)) ([11162da](ChromeDevTools@11162da)) * add service workers to get_console_message ([ChromeDevTools#3537](ChromeDevTools#3537)) ([2e247a4](ChromeDevTools@2e247a4)) * include computed styles in get_css_styles ([ChromeDevTools#3538](ChromeDevTools#3538)) ([cf98d8b](ChromeDevTools@cf98d8b)) * list errors a page raises while a tool runs ([ChromeDevTools#3431](ChromeDevTools#3431)) ([d5d30bd](ChromeDevTools@d5d30bd)) * resolve CSS custom variable values inline in `get_css_styles` ([ChromeDevTools#3481](ChromeDevTools#3481)) ([8ba2ac9](ChromeDevTools@8ba2ac9)) * support transparent screenshots ([ChromeDevTools#3457](ChromeDevTools#3457)) ([045fb8c](ChromeDevTools@045fb8c)) * **telemetry:** send startup events directly from the server process ([ChromeDevTools#3511](ChromeDevTools#3511)) ([b14eb81](ChromeDevTools@b14eb81)) ### 🛠️ Fixes * accept POSIX root URIs from WSL2 clients on a Windows server ([ChromeDevTools#3380](ChromeDevTools#3380)) ([4b9acc9](ChromeDevTools@4b9acc9)) * align root plugin.json name with marketplace entry ([ChromeDevTools#3474](ChromeDevTools#3474)) ([1424980](ChromeDevTools@1424980)) * **cli:** enable off by default categories in CLI except PWA ([ChromeDevTools#3595](ChromeDevTools#3595)) ([0ff265d](ChromeDevTools@0ff265d)) * **cli:** handle array of strings correctly ([ChromeDevTools#3593](ChromeDevTools#3593)) ([d197b28](ChromeDevTools@d197b28)) * **cli:** match yargs-parser when detecting negative numbers ([ChromeDevTools#3548](ChromeDevTools#3548)) ([eb9b030](ChromeDevTools@eb9b030)) * **cli:** pass option values starting with `-` through to tools ([ChromeDevTools#3501](ChromeDevTools#3501)) ([ec0abfc](ChromeDevTools@ec0abfc)) * **cli:** preserve daemon PID when SIGKILL fails ([ChromeDevTools#3485](ChromeDevTools#3485)) ([0788697](ChromeDevTools@0788697)) * **cli:** reuse live daemons after EPERM ([ChromeDevTools#3452](ChromeDevTools#3452)) ([1417f93](ChromeDevTools@1417f93)) * **cli:** strip terminal escape sequences from tool output and errors ([ChromeDevTools#3536](ChromeDevTools#3536)) ([ec2fb15](ChromeDevTools@ec2fb15)) * **config:** reject --browserUrl values without an http(s) scheme ([ChromeDevTools#3437](ChromeDevTools#3437)) ([e40cef6](ChromeDevTools@e40cef6)) * **config:** reject --viewport values with more than two parts ([ChromeDevTools#3577](ChromeDevTools#3577)) ([ab911a6](ChromeDevTools@ab911a6)) * **console:** keep stack traces of messages from earlier navigations ([ChromeDevTools#3397](ChromeDevTools#3397)) ([e8798d6](ChromeDevTools@e8798d6)) * **console:** resolve Error arguments on the session of their handle ([ChromeDevTools#3408](ChromeDevTools#3408)) ([4c6c767](ChromeDevTools@4c6c767)) * dedicated worker can now build a stack trace ([ChromeDevTools#3572](ChromeDevTools#3572)) ([9762165](ChromeDevTools@9762165)), closes [ChromeDevTools#2962](ChromeDevTools#2962) * do not queue unknown page ids ([ChromeDevTools#3599](ChromeDevTools#3599)) ([4dc8cbc](ChromeDevTools@4dc8cbc)) * **emulation:** reject non-string extraHttpHeaders values ([ChromeDevTools#3484](ChromeDevTools#3484)) ([64d4726](ChromeDevTools@64d4726)) * explain DevToolsActivePort permission errors during autoConnect ([ChromeDevTools#3487](ChromeDevTools#3487)) ([0e49c59](ChromeDevTools@0e49c59)) * **extensions:** preserve list_extensions fields in JSON output ([ChromeDevTools#3592](ChromeDevTools#3592)) ([02b146b](ChromeDevTools@02b146b)) * **input:** allow multi-file upload_file through chooser-opening elements ([ChromeDevTools#3436](ChromeDevTools#3436)) ([ef680a3](ChromeDevTools@ef680a3)) * **input:** return when click_at, type_text, drag or press_key opens a dialog ([ChromeDevTools#3576](ChromeDevTools#3576)) ([7bcb86d](ChromeDevTools@7bcb86d)) * keep temp files under the temp dir ([ChromeDevTools#3372](ChromeDevTools#3372)) ([d666acf](ChromeDevTools@d666acf)) * remove commands from claude plugin ([ChromeDevTools#3469](ChromeDevTools#3469)) ([e2f08b4](ChromeDevTools@e2f08b4)) * respect tool timeouts in CLI daemon responses ([ChromeDevTools#3443](ChromeDevTools#3443)) ([86a1c23](ChromeDevTools@86a1c23)) * **snapshot:** keep extra element UIDs reusable ([ChromeDevTools#3493](ChromeDevTools#3493)) ([4559cd5](ChromeDevTools@4559cd5)) * treat local host name and interface addresses as local browser endpoints ([ChromeDevTools#3463](ChromeDevTools#3463)) ([cf587b4](ChromeDevTools@cf587b4)) * use exception events instead of Runtime.exceptionThrown ([ChromeDevTools#3553](ChromeDevTools#3553)) ([437f394](ChromeDevTools@437f394)) * validate heap snapshot className regex ([ChromeDevTools#3030](ChromeDevTools#3030)) ([343e6b1](ChromeDevTools@343e6b1)) * validate install_pwa and launch_pwa URLs against navigation policy ([ChromeDevTools#3464](ChromeDevTools#3464)) ([057a6aa](ChromeDevTools@057a6aa)) * wait for parsed scripts before reporting an unknown logpoint URL ([ChromeDevTools#3461](ChromeDevTools#3461)) ([404f331](ChromeDevTools@404f331)) ### 📄 Documentation * clarify that Chrome may clamp resize_page dimensions ([ChromeDevTools#3583](ChromeDevTools#3583)) ([b5a41e0](ChromeDevTools@b5a41e0)), closes [ChromeDevTools#2998](ChromeDevTools#2998) * explain the light and browser third-party bundles in AGENTS.md ([ChromeDevTools#3529](ChromeDevTools#3529)) ([835c09a](ChromeDevTools@835c09a)) * fix typos in comments, tests and skill docs ([ChromeDevTools#3489](ChromeDevTools#3489)) ([f312b72](ChromeDevTools@f312b72)) ### ⚡ Performance * **telemetry:** start the watchdog process on the first event that needs it ([ChromeDevTools#3513](ChromeDevTools#3513)) ([a4c550d](ChromeDevTools@a4c550d)) ### 🏗️ Refactor * **build:** split Puppeteer and DevTools into a separate bundle ([ChromeDevTools#3510](ChromeDevTools#3510)) ([1067857](ChromeDevTools@1067857)) * **config:** import ConfigWatcher without the browser bundle ([ChromeDevTools#3520](ChromeDevTools#3520)) ([24dba69](ChromeDevTools@24dba69)) * create BrowserManager without the browser bundle ([ChromeDevTools#3563](ChromeDevTools#3563)) ([e8763f9](ChromeDevTools@e8763f9)) * **formatters:** rename MAX_NAME_LENGTH to HEAP_SNAPSHOT_MAX_NAME_LENGTH ([ChromeDevTools#3591](ChromeDevTools#3591)) ([92250bc](ChromeDevTools@92250bc)) * load DevTools in HeapSnapshotManager on first use ([ChromeDevTools#3564](ChromeDevTools#3564)) ([d8035c6](ChromeDevTools@d8035c6)) * load McpResponse when ToolHandler builds a response ([ChromeDevTools#3565](ChromeDevTools#3565)) ([e4669b3](ChromeDevTools@e4669b3)) * **telemetry:** extract sending to Clearcut into sendToClearcut() ([ChromeDevTools#3509](ChromeDevTools#3509)) ([7354c59](ChromeDevTools@7354c59)) * **telemetry:** generate the session id in ClearcutLogger ([ChromeDevTools#3516](ChromeDevTools#3516)) ([ea19ce7](ChromeDevTools@ea19ce7)) * **telemetry:** import flagUtils without the browser bundle ([ChromeDevTools#3518](ChromeDevTools#3518)) ([ab046de](ChromeDevTools@ab046de)) * **third_party:** re-export Mutex from the light bundle ([ChromeDevTools#3566](ChromeDevTools#3566)) ([48466c4](ChromeDevTools@48466c4)) * **tools:** import emulation without the browser bundle ([ChromeDevTools#3521](ChromeDevTools#3521)) ([c5d5d7f](ChromeDevTools@c5d5d7f)) * **tools:** import input without the browser bundle ([ChromeDevTools#3522](ChromeDevTools#3522)) ([bdecb63](ChromeDevTools@bdecb63)) * **tools:** import logpoints without the browser bundle ([ChromeDevTools#3525](ChromeDevTools#3525)) ([71098b0](ChromeDevTools@71098b0)) * **tools:** import memory without the browser bundle ([ChromeDevTools#3526](ChromeDevTools#3526)) ([ebb27f9](ChromeDevTools@ebb27f9)) * **tools:** import performance without the browser bundle ([ChromeDevTools#3524](ChromeDevTools#3524)) ([ba76587](ChromeDevTools@ba76587)) * **tools:** import snapshot without the browser bundle ([ChromeDevTools#3523](ChromeDevTools#3523)) ([110d7f3](ChromeDevTools@110d7f3)) * **utils:** import text utilities without the browser bundle ([ChromeDevTools#3519](ChromeDevTools#3519)) ([8029df8](ChromeDevTools@8029df8)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
1 task
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.
Refs #3427
Lazy loading: server startup part a, stacked on #3566. Part of splitting "the server doesn't load
third_party/browser.jsat startup" into small PRs (3a–3f). Behavior doesn't change.What changed
src/BrowserManager.ts:third_party/browser.js.loadBrowser()through a smallloadPuppeteer()helper, called right beforepuppeteer.launch()in#launch()and beforepuppeteer.connect()in#connect().ConnectOptionsinstead ofParameters<typeof puppeteer.connect>[0], which is the same type.tryaroundconnect(), so a load failure isn't reported as "Could not connect to Chrome".puppeteer.setFollowSymlinks(false):src/index.tsintoloadPuppeteer(), so it runs before every launch and every connect.createMcpServer()andMcpServer.from(config, {browserManager}), launches or connects only throughBrowserManager, so Puppeteer's file reads and writes still don't follow symlinks.@puppeteer/browsers(detectBrowserPlatform,resolveDefaultUserDataDir,BrowserEnum) isn't used byBrowserManager, only bytests/utils.ts, so nothing to change.McpServerOptions.browserManager,createMcpServer()and theBrowserManagerconstructor.src/BrowserManager.tsis added to the@typescript-eslint/no-restricted-importsblock that rejects value imports frombrowser.js.Modules now in both bundles
None new.
What still loads browser.js at startup
From a static walk of the built JS, starting at
bin/chrome-devtools-mcp-main.jsanddaemon/daemon.js.BrowserManager.jsno longer appears:HeapSnapshotManager,ToolHandlerandMcpContextare handled by parts b, c and d.Test plan
New tests in
tests/browser.test.ts:disables following symlinks in Puppeteer before launchingdisables following symlinks in Puppeteer before connectingEach asserts
setFollowSymlinks(false)is called once and beforelaunch()orconnect(). Both would fail without this change, because the test file never importssrc/index.ts.npm run test tests/browser.test.ts tests/McpServer.test.ts tests/index.test.ts, andnpm run format.Full
npm run teston the top of the series.