getHttpErrorStatus (src/retry.ts)

sync-engine · packages/source-stripe/src/retry.ts · typescript · Apache-2.0
payments

HTTP retry helper that retries requests on network or server errors with exponential backoff.

// Source: https://github.com/stripe/sync-engine | 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.
import { log } from './logger.js'

const BACKOFF_BASE_MS = 1000
const BACKOFF_MAX_MS = 32000
const MAX_RETRIES = 5

const RETRYABLE_NETWORK_CODES = new Set([
  'ECONNRESET',
  'ECONNREFUSED',
  'ETIMEDOUT',
  'EAI_AGAIN',
  'ENOTFOUND',
  'UND_ERR_CONNECT_TIMEOUT',
  'UND_ERR_HEADERS_TIMEOUT',
  'UND_ERR_BODY_TIMEOUT',
  'UND_ERR_SOCKET',
])

export type HttpRetryOptions = {
  /** Human-readable label for log messages (e.g. "GET /v1/customers") */
  label?: string
  maxRetries?: number
  baseDelayMs?: number
  maxDelayMs?: number
  signal?: AbortSignal
}

export function getHttpErrorSt

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

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

Get a free API key