fix(proxy): Add error handling to proxy agent creation (#11538)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
Shreya Keshive
2025-10-21 12:43:37 -07:00
committed by GitHub
parent 62dc9683bd
commit e72c00cf9a
3 changed files with 17 additions and 6 deletions
+6 -3
View File
@@ -21,9 +21,12 @@ import { getErrorMessage } from '../utils/errors.js';
import type { Config } from '../config/config.js';
import { ApprovalMode, DEFAULT_GEMINI_FLASH_MODEL } from '../config/config.js';
import { getResponseText } from '../utils/partUtils.js';
import { fetchWithTimeout, isPrivateIp } from '../utils/fetch.js';
import {
fetchWithTimeout,
isPrivateIp,
setGlobalProxy,
} from '../utils/fetch.js';
import { convert } from 'html-to-text';
import { ProxyAgent, setGlobalDispatcher } from 'undici';
import {
logWebFetchFallbackAttempt,
WebFetchFallbackAttemptEvent,
@@ -425,7 +428,7 @@ export class WebFetchTool extends BaseDeclarativeTool<
);
const proxy = config.getProxy();
if (proxy) {
setGlobalDispatcher(new ProxyAgent(proxy as string));
setGlobalProxy(proxy);
}
}