mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
fix(core): apply retry logic to CodeAssistServer for all users (#20507)
This commit is contained in:
@@ -73,8 +73,7 @@ describe('CodeAssistServer', () => {
|
|||||||
LlmRole.MAIN,
|
LlmRole.MAIN,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mockRequest).toHaveBeenCalledWith(
|
expect(mockRequest).toHaveBeenCalledWith({
|
||||||
expect.objectContaining({
|
|
||||||
url: expect.stringContaining(':generateContent'),
|
url: expect.stringContaining(':generateContent'),
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -84,8 +83,16 @@ describe('CodeAssistServer', () => {
|
|||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
body: expect.any(String),
|
body: expect.any(String),
|
||||||
signal: undefined,
|
signal: undefined,
|
||||||
}),
|
retryConfig: {
|
||||||
);
|
retry: 3,
|
||||||
|
noResponseRetries: 3,
|
||||||
|
statusCodesToRetry: [
|
||||||
|
[429, 429],
|
||||||
|
[499, 499],
|
||||||
|
[500, 599],
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const requestBody = JSON.parse(mockRequest.mock.calls[0][0].body);
|
const requestBody = JSON.parse(mockRequest.mock.calls[0][0].body);
|
||||||
expect(requestBody.user_prompt_id).toBe('user-prompt-id');
|
expect(requestBody.user_prompt_id).toBe('user-prompt-id');
|
||||||
@@ -393,8 +400,7 @@ describe('CodeAssistServer', () => {
|
|||||||
results.push(res);
|
results.push(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(mockRequest).toHaveBeenCalledWith(
|
expect(mockRequest).toHaveBeenCalledWith({
|
||||||
expect.objectContaining({
|
|
||||||
url: expect.stringContaining(':streamGenerateContent'),
|
url: expect.stringContaining(':streamGenerateContent'),
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
params: { alt: 'sse' },
|
params: { alt: 'sse' },
|
||||||
@@ -404,8 +410,16 @@ describe('CodeAssistServer', () => {
|
|||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
signal: undefined,
|
signal: undefined,
|
||||||
}),
|
retryConfig: {
|
||||||
);
|
retry: 3,
|
||||||
|
noResponseRetries: 3,
|
||||||
|
statusCodesToRetry: [
|
||||||
|
[429, 429],
|
||||||
|
[499, 499],
|
||||||
|
[500, 599],
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
expect(results).toHaveLength(2);
|
expect(results).toHaveLength(2);
|
||||||
expect(results[0].candidates?.[0].content?.parts?.[0].text).toBe('Hello');
|
expect(results[0].candidates?.[0].content?.parts?.[0].text).toBe('Hello');
|
||||||
|
|||||||
@@ -305,6 +305,15 @@ export class CodeAssistServer implements ContentGenerator {
|
|||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
body: JSON.stringify(req),
|
body: JSON.stringify(req),
|
||||||
signal,
|
signal,
|
||||||
|
retryConfig: {
|
||||||
|
retry: 3,
|
||||||
|
noResponseRetries: 3,
|
||||||
|
statusCodesToRetry: [
|
||||||
|
[429, 429],
|
||||||
|
[499, 499],
|
||||||
|
[500, 599],
|
||||||
|
],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
@@ -352,6 +361,15 @@ export class CodeAssistServer implements ContentGenerator {
|
|||||||
responseType: 'stream',
|
responseType: 'stream',
|
||||||
body: JSON.stringify(req),
|
body: JSON.stringify(req),
|
||||||
signal,
|
signal,
|
||||||
|
retryConfig: {
|
||||||
|
retry: 3,
|
||||||
|
noResponseRetries: 3,
|
||||||
|
statusCodesToRetry: [
|
||||||
|
[429, 429],
|
||||||
|
[499, 499],
|
||||||
|
[500, 599],
|
||||||
|
],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return (async function* (): AsyncGenerator<T> {
|
return (async function* (): AsyncGenerator<T> {
|
||||||
|
|||||||
Reference in New Issue
Block a user