fix(core): disable retries for code assist streaming requests (#20561)

This commit is contained in:
Sehoon Shon
2026-02-27 13:04:43 -05:00
committed by GitHub
parent 23905bcd77
commit fdd844b405
2 changed files with 7 additions and 18 deletions

View File

@@ -84,6 +84,7 @@ describe('CodeAssistServer', () => {
body: expect.any(String),
signal: undefined,
retryConfig: {
retryDelay: 1000,
retry: 3,
noResponseRetries: 3,
statusCodesToRetry: [
@@ -410,15 +411,7 @@ describe('CodeAssistServer', () => {
'Content-Type': 'application/json',
},
signal: undefined,
retryConfig: {
retry: 3,
noResponseRetries: 3,
statusCodesToRetry: [
[429, 429],
[499, 499],
[500, 599],
],
},
retry: false,
});
expect(results).toHaveLength(2);

View File

@@ -62,6 +62,7 @@ export interface HttpOptions {
export const CODE_ASSIST_ENDPOINT = 'https://cloudcode-pa.googleapis.com';
export const CODE_ASSIST_API_VERSION = 'v1internal';
const GENERATE_CONTENT_RETRY_DELAY_IN_MILLISECONDS = 1000;
export class CodeAssistServer implements ContentGenerator {
constructor(
@@ -141,6 +142,7 @@ export class CodeAssistServer implements ContentGenerator {
this.sessionId,
),
req.config?.abortSignal,
GENERATE_CONTENT_RETRY_DELAY_IN_MILLISECONDS,
);
const duration = formatProtoJsonDuration(Date.now() - start);
const streamingLatency: StreamingLatency = {
@@ -294,6 +296,7 @@ export class CodeAssistServer implements ContentGenerator {
method: string,
req: object,
signal?: AbortSignal,
retryDelay: number = 100,
): Promise<T> {
const res = await this.client.request<T>({
url: this.getMethodUrl(method),
@@ -306,6 +309,7 @@ export class CodeAssistServer implements ContentGenerator {
body: JSON.stringify(req),
signal,
retryConfig: {
retryDelay,
retry: 3,
noResponseRetries: 3,
statusCodesToRetry: [
@@ -361,15 +365,7 @@ export class CodeAssistServer implements ContentGenerator {
responseType: 'stream',
body: JSON.stringify(req),
signal,
retryConfig: {
retry: 3,
noResponseRetries: 3,
statusCodesToRetry: [
[429, 429],
[499, 499],
[500, 599],
],
},
retry: false,
});
return (async function* (): AsyncGenerator<T> {