Skip to content

test: guard lazy browser bundle loading and tighten idle memory budgets - #3574

Merged
yulunz merged 1 commit into
mainfrom
test/guard-lazy-browser-startup
Nov 26, 2026
Merged

yulunz merged 1 commit into
mainfrom
test/guard-lazy-browser-startup

Conversation

@yulunz

@yulunz yulunz commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #3427

Lazy loading: server startup part f (final part of 3a–3f), stacked on #3573. Guards the lazy startup boundary end-to-end, tightens the idle private-memory budgets so any regression that eagerly loads third_party/browser.js fails CI, and syncs AGENTS.md.

What changed

  • Runtime module-load e2e test (tests/e2e/lazy-startup.test.ts, tests/BUILD.gn):
    • Spawns bin/chrome-devtools-mcp.js --usage-statistics=false --browserUrl=http://127.0.0.1:1 with a node:module register() loader hook passed via --import.
    • Completes initialize and tools/list, asserts third_party/index.js was recorded by the hook and third_party/browser.js was not loaded, then invokes list_pages (failing fast against 127.0.0.1:1 without launching Chrome) and asserts third_party/browser.js was loaded.
    • Normalizes file:// URLs with fileURLToPath + fs.realpathSync for cross-platform paths across Linux, macOS, and Windows, and waits for server exit before using tempDir = createTempDir(...) cleans up.
    • Verified that the startup assertion fails against pre-perf: create McpContext on the first tool call #3568 src/index.ts.
  • Tightened idle private-memory budgets (scripts/profile/footprint_mcp.ts):
    • Lowers default from 112 MiB to 40 MiB and no-usage-statistics from 110 MiB to 38 MiB, updating the baseline comment.
    • On Ubuntu x64 CI (test-memory-leaks.yml, Node 22 LTS), medians are 35.92 MiB (default) and 34.17 MiB (no-usage-statistics), so both budgets sit ~11% above CI medians (locally on Linux x64 with Node v24.12.0 LTS, medians are 46.02 MiB and 43.49 MiB) and less than half the ~93 MiB footprint when third_party/browser.js loads eagerly.
  • Documentation (AGENTS.md):
    • Updates Third-party bundles and the Design checklist to state that third_party/browser.js is not loaded at server startup and list all paths covered by the ESLint @typescript-eslint/no-restricted-imports rules (src/index.ts, src/BrowserManager.ts, src/processors/HeapSnapshotManager.ts, src/ToolHandler.ts, src/bin/, src/daemon/, src/tools/, src/config/, and src/telemetry/ for browser.js, plus ./McpContext.js in src/index.ts).

Test plan

  • npm run test tests/e2e/lazy-startup.test.ts (and verified failure before perf: create McpContext on the first tool call #3568).
  • npm run profile:footprint on Ubuntu x64 Node 22 LTS CI (and local 5-launch verification on Node v24.12.0 LTS).
  • npm run format and full npm run test.

@yulunz
yulunz added this pull request to stack #3567 November 20, 2026 22:37
@Lightning00Blade
Lightning00Blade force-pushed the test/guard-lazy-browser-startup branch from 97b50b9 to 3c23dd1 Compare November 23, 2026 12:36
@Lightning00Blade
Lightning00Blade self-requested a review November 23, 2026 12:39
@Lightning00Blade
Lightning00Blade force-pushed the test/guard-lazy-browser-startup branch 3 times, most recently from 6ca4056 to d315659 Compare November 23, 2026 14:33
Comment thread scripts/profile/footprint_mcp.ts Resolved
Comment thread scripts/profile/footprint_mcp.ts Resolved
@yulunz
yulunz force-pushed the test/guard-lazy-browser-startup branch from d315659 to 40b986d Compare November 24, 2026 19:53
Base automatically changed from perf/lazy-issue-descriptions to main November 25, 2026 13:30
Add an e2e loader-hook test verifying that third_party/browser.js is not
loaded during MCP server startup or tools/list and loads on the first
tool call, lower the idle private-memory budgets in footprint_mcp.ts
from 112/110 MiB to 40/38 MiB (~11% above CI Node 22 LTS medians), and
sync AGENTS.md with the completed lazy-startup rules.

Refs #3427
@yulunz
yulunz force-pushed the test/guard-lazy-browser-startup branch from 40b986d to df17264 Compare November 25, 2026 13:30
@yulunz
yulunz added this pull request to the merge queue Nov 26, 2026
Merged via the queue into main with commit faa6c87 Nov 26, 2026
17 checks passed
@yulunz
yulunz deleted the test/guard-lazy-browser-startup branch November 26, 2026 15:28
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