Repository navigation
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2f96611632
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (!shouldBypassProxyForCdp(cdpUrl)) { | ||
| return undefined; | ||
| } | ||
| return new Agent({ connect: { proxy: undefined } }); |
There was a problem hiding this comment.
Reuse or close loopback CDP agents
Creating a new Agent for every loopback probe without ever closing it introduces avoidable connection-pool churn and lingering sockets during repeated health checks (for example the startup and shutdown polling loops that call isChromeReachable many times). This means loopback profiles can accumulate transient undici pools/file descriptors under frequent probes, which is a regression from the previous single global dispatcher path; please either reuse a shared dispatcher for loopback probes or close the per-request agent in finally.
Useful? React with 👍 / 👎.
Greptile SummaryThis PR fixes browser startup failures when HTTP proxy environment variables are configured. The root cause was that CDP health checks to loopback addresses (127.0.0.1) were incorrectly routing through proxy infrastructure, causing timeouts even when Chrome was running locally. Key changes:
Implementation quality:
The fix is targeted, well-implemented, and directly addresses the reported issue without introducing side effects. Confidence Score: 5/5
Last reviewed commit: 2f96611 |
Summary
Fixes browser startup failures when HTTP proxy env vars are set by ensuring loopback CDP health checks do not route through EnvHttpProxyAgent.
Closes #31219
Root cause
isChromeReachable()probeshttp://127.0.0.1:<port>/json/versionvia globalfetch. WhenHTTP_PROXY/HTTPS_PROXY/ALL_PROXYis configured, undici may route this loopback probe through proxy infrastructure, causing timeout/failure even though Chrome is healthy on localhost.Changes
src/browser/chrome.ts:isLoopbackHost.Agent({ connect: { proxy: undefined } })dispatcher tofetchso the request bypasses env proxy routing.src/browser/chrome.test.ts:Validation
pnpm exec vitest run --config vitest.unit.config.ts src/browser/chrome.test.ts