You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running openclaw config to authenticate with Google Gemini CLI OAuth, the exchangeCodeForTokens step fails with AbortError: This operation was aborted on machines that require an HTTP proxy to reach Google's servers.
Root Cause
In google-gemini-cli-auth/oauth.ts, the fetchWithTimeout call uses fetchWithSsrFGuard which defaults to createPinnedDispatcher mode. This dispatcher resolves the hostname to an IP and connects directly, bypassing the system proxy environment variables (http_proxy/https_proxy/HTTPS_PROXY).
The relevant branch in fetchWithSsrFGuard:
if(mode===GUARDED_FETCH_MODE.TRUSTED_ENV_PROXY&&hasProxyEnvConfigured())dispatcher=newEnvHttpProxyAgent();// ← this path is NOT taken for OAuthelseif(params.pinDns!==false)dispatcher=createPinnedDispatcher(pinned);// ← direct IP, bypasses proxy
Since exchangeCodeForTokens (oauth.ts:414) posts to https://oauth2.googleapis.com/token, on machines where direct outbound connections to Google IPs are blocked (common in China / corporate networks), the request times out and throws AbortError.
Reproduction
Set up a machine where https_proxy=http://<proxy>:<port> is required to reach Google
Confirm curl https://oauth2.googleapis.com/ works (via proxy)
Confirm direct IP connection to 172.253.117.95:443 times out (no proxy)
Run openclaw config → select Google → Gemini CLI OAuth
Complete browser authentication successfully
Observe: AbortError: This operation was aborted at exchangeCodeForTokens
Expected Behavior
The OAuth token exchange request should respect the system proxy settings (HTTPS_PROXY/https_proxy) and use EnvHttpProxyAgent (or equivalent) when proxy env vars are configured.
Suggested Fix
Pass pinDns: false or use TRUSTED_ENV_PROXY mode for the fetchWithSsrFGuard call in exchangeCodeForTokens (and ideally all OAuth-related fetches in the plugin):
const{ response, release }=awaitfetchWithSsrFGuard({url: TOKEN_URL,init: { ... },// Add this to respect system proxy:pinDns: false,// or use TRUSTED_ENV_PROXY mode});
Environment
OpenClaw version: 2026.3.2
OS: Linux Ubuntu (x64)
Node.js: v24.13.1
Network: HTTP proxy required for external access (https_proxy=http://192.168.31.99:8910)
no_proxy correctly excludes LAN ranges, but Google IPs require proxy
When attempting with NODE_OPTIONS="--dns-result-order=ipv4first" GLOBAL_AGENT_HTTP_PROXY=... workaround, the error changes to TypeError: fetch failed (immediate network rejection rather than timeout):
[openclaw] Failed to start CLI: TypeError: fetch failed
at node:internal/deps/undici/undici:16416:13
at async fetchWithSsrFGuard (.../fetch-guard-TrC02Qcz.js:117:24)
at async fetchWithTimeout (.../oauth.ts:244:33)
at async exchangeCodeForTokens (.../oauth.ts:414:20)
Both AbortError: This operation was aborted (timeout) and TypeError: fetch failed (immediate rejection) stem from the same root cause — createPinnedDispatcher bypasses system proxy and attempts a direct connection to Google's IP, which is blocked.
The NODE_OPTIONS / GLOBAL_AGENT_HTTP_PROXY workaround has no effect because fetchWithSsrFGuard uses its own undici dispatcher, not the global Node.js http agent.
This allows fetchWithSsrFGuard to fall through to EnvHttpProxyAgent when proxy env vars are configured, instead of using createPinnedDispatcher which bypasses the proxy entirely.
After applying this patch, the OAuth token exchange successfully completes through the system proxy.
Closing due to inactivity.
If this is still an issue, please retry on the latest OpenClaw release and share updated details.
If you are absolutely sure it still happens on the latest release, open a new issue with fresh repro steps.
Activity
lyfuci commentedon Mar 4, 2026
Additional Error Variant
When attempting with
NODE_OPTIONS="--dns-result-order=ipv4first" GLOBAL_AGENT_HTTP_PROXY=...workaround, the error changes toTypeError: fetch failed(immediate network rejection rather than timeout):Both
AbortError: This operation was aborted(timeout) andTypeError: fetch failed(immediate rejection) stem from the same root cause —createPinnedDispatcherbypasses system proxy and attempts a direct connection to Google's IP, which is blocked.The
NODE_OPTIONS/GLOBAL_AGENT_HTTP_PROXYworkaround has no effect becausefetchWithSsrFGuarduses its ownundicidispatcher, not the global Node.js http agent.lyfuci commentedon Mar 4, 2026
Local Patch (workaround until official fix)
Applied the following patch to
extensions/google-gemini-cli-auth/oauth.ts:const { response, release } = await fetchWithSsrFGuard({ url, init, timeoutMs, + pinDns: false, });This allows
fetchWithSsrFGuardto fall through toEnvHttpProxyAgentwhen proxy env vars are configured, instead of usingcreatePinnedDispatcherwhich bypasses the proxy entirely.After applying this patch, the OAuth token exchange successfully completes through the system proxy.
fix(google-gemini-cli-auth): respect system proxy for OAuth token exc…
openclaw-barnacle commentedon Apr 14, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.
openclaw-barnacle commentedon Apr 21, 2026
Closing due to inactivity.
If this is still an issue, please retry on the latest OpenClaw release and share updated details.
If you are absolutely sure it still happens on the latest release, open a new issue with fresh repro steps.