Stream Transport Retry (core/stream-transport-retry.ts)

qwen-code · packages/core/src/core/stream-transport-retry.ts · typescript · Apache-2.0
ai, infra, realtime, tag:retry, tag:transport, tag:genai, tag:error

Defines retryable error codes for stream transport in a GenAI context. Use to implement robust retry logic for streaming API calls.

// Source: https://github.com/QwenLM/qwen-code | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * @license
 * Copyright 2026 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */

import type { GenerateContentResponse } from '@google/genai';

import type { RetryErrorClassification } from '../utils/retryErrorClassification.js';

// Internal stream retry allow-list. Keep this outside llm-chat.ts because
// that file is re-exported from the package barrel, and this retry policy is
// not part of the public API.
export const RETRYABLE_STREAM_TRANSPORT_CODES: ReadonlySet<string> = new Set([
  'ECONNRESET',
  'ETIMEDOUT',
  'UND_ERR_BODY_TIMEOUT',
  'UND_ERR_CONNECT_TIMEOUT',
  'UND

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key