mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-22 19:14:33 -07:00
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:
@@ -6,6 +6,7 @@
|
||||
|
||||
import { getErrorMessage, isNodeError } from './errors.js';
|
||||
import { URL } from 'node:url';
|
||||
import { ProxyAgent, setGlobalDispatcher } from 'undici';
|
||||
|
||||
const PRIVATE_IP_RANGES = [
|
||||
/^10\./,
|
||||
@@ -55,3 +56,11 @@ export async function fetchWithTimeout(
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
}
|
||||
|
||||
export function setGlobalProxy(proxy: string) {
|
||||
try {
|
||||
setGlobalDispatcher(new ProxyAgent(proxy));
|
||||
} catch (e) {
|
||||
console.error(`Failed to set proxy: ${getErrorMessage(e)}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user