mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-31 06:02:47 -07:00
refactor(core): use global undici timeouts instead of hard request timeouts
This commit is contained in:
@@ -84,7 +84,6 @@ describe('CodeAssistServer', () => {
|
||||
responseType: 'json',
|
||||
body: expect.any(String),
|
||||
signal: undefined,
|
||||
timeout: 60000,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -405,7 +404,6 @@ describe('CodeAssistServer', () => {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
signal: undefined,
|
||||
timeout: 60000,
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -305,7 +305,6 @@ export class CodeAssistServer implements ContentGenerator {
|
||||
responseType: 'json',
|
||||
body: JSON.stringify(req),
|
||||
signal,
|
||||
timeout: 60000,
|
||||
});
|
||||
return res.data;
|
||||
}
|
||||
@@ -353,7 +352,6 @@ export class CodeAssistServer implements ContentGenerator {
|
||||
responseType: 'stream',
|
||||
body: JSON.stringify(req),
|
||||
signal,
|
||||
timeout: 60000,
|
||||
});
|
||||
|
||||
return (async function* (): AsyncGenerator<T> {
|
||||
|
||||
@@ -206,7 +206,7 @@ export async function createContentGenerator(
|
||||
'x-gemini-api-privileged-user-id': `${installationId}`,
|
||||
};
|
||||
}
|
||||
const httpOptions = { headers, timeout: 60000 };
|
||||
const httpOptions = { headers };
|
||||
|
||||
const googleGenAI = new GoogleGenAI({
|
||||
apiKey: config.apiKey === '' ? undefined : config.apiKey,
|
||||
|
||||
@@ -6,7 +6,18 @@
|
||||
|
||||
import { getErrorMessage, isNodeError } from './errors.js';
|
||||
import { URL } from 'node:url';
|
||||
import { ProxyAgent, setGlobalDispatcher } from 'undici';
|
||||
import { Agent, ProxyAgent, setGlobalDispatcher } from 'undici';
|
||||
|
||||
const DEFAULT_HEADERS_TIMEOUT = 60000; // 60 seconds
|
||||
const DEFAULT_BODY_TIMEOUT = 300000; // 5 minutes
|
||||
|
||||
// Configure default global dispatcher with higher timeouts
|
||||
setGlobalDispatcher(
|
||||
new Agent({
|
||||
headersTimeout: DEFAULT_HEADERS_TIMEOUT,
|
||||
bodyTimeout: DEFAULT_BODY_TIMEOUT,
|
||||
}),
|
||||
);
|
||||
|
||||
const PRIVATE_IP_RANGES = [
|
||||
/^10\./,
|
||||
@@ -73,5 +84,11 @@ export async function fetchWithTimeout(
|
||||
}
|
||||
|
||||
export function setGlobalProxy(proxy: string) {
|
||||
setGlobalDispatcher(new ProxyAgent(proxy));
|
||||
setGlobalDispatcher(
|
||||
new ProxyAgent({
|
||||
uri: proxy,
|
||||
headersTimeout: DEFAULT_HEADERS_TIMEOUT,
|
||||
bodyTimeout: DEFAULT_BODY_TIMEOUT,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user