{"version":3,"file":"async_caller.cjs","names":["getRetryable","stampRetryable","PQueueMod","pRetry","getAbortSignalError"],"sources":["../../src/utils/async_caller.ts"],"sourcesContent":["import PQueueMod from \"p-queue\";\n\nimport { getRetryable, stampRetryable } from \"../errors/index.js\";\nimport { getAbortSignalError } from \"./signal.js\";\nimport pRetry from \"./p-retry/index.js\";\n\nconst STATUS_NO_RETRY = [\n  400, // Bad Request\n  401, // Unauthorized\n  402, // Payment Required\n  403, // Forbidden\n  404, // Not Found\n  405, // Method Not Allowed\n  406, // Not Acceptable\n  407, // Proxy Authentication Required\n  409, // Conflict\n  413, // Payload Too Large\n];\n\nconst RETRY_AFTER_AUTO_RETRY_THRESHOLD_MS = 60_000;\n\nconst QUOTA_EXHAUSTED_MESSAGE_PATTERNS = [\n  /insufficient[_ -]?quota/i,\n  /exceeded (?:your|the current|the available).+quota/i,\n  /usage quota/i,\n  /quota (?:has been )?exhausted/i,\n  /billing/i,\n  /credit balance/i,\n  /out of credits/i,\n  /will reset at/i,\n];\n\nconst RETRY_AFTER_MESSAGE_PATTERN =\n  /(?:try again in|retry after)\\s+(\\d+(?:\\.\\d+)?)\\s*(milliseconds?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h)\\b/i;\n\ntype RateLimitAction = \"wait\" | \"capacity\" | \"stop\";\n\ntype RateLimitClassification = {\n  action: RateLimitAction;\n  retryAfterMs?: number;\n  reason: string;\n};\n\nfunction getResponseStatus(error: unknown): number | undefined {\n  return typeof error === \"object\" &&\n    error !== null &&\n    \"response\" in error &&\n    typeof error.response === \"object\" &&\n    error.response !== null &&\n    \"status\" in error.response &&\n    typeof error.response.status === \"number\"\n    ? error.response.status\n    : undefined;\n}\n\nfunction getDirectStatus(error: unknown): number | undefined {\n  if (typeof error !== \"object\" || error === null) {\n    return undefined;\n  }\n\n  if (\"status\" in error && typeof error.status === \"number\") {\n    return error.status;\n  }\n\n  if (\"statusCode\" in error && typeof error.statusCode === \"number\") {\n    return error.statusCode;\n  }\n\n  return undefined;\n}\n\nfunction getErrorMessage(error: unknown): string | undefined {\n  return typeof error === \"object\" &&\n    error !== null &&\n    \"message\" in error &&\n    typeof error.message === \"string\"\n    ? error.message\n    : undefined;\n}\n\nfunction getErrorCode(error: unknown): string | undefined {\n  if (typeof error !== \"object\" || error === null) {\n    return undefined;\n  }\n\n  if (\"code\" in error && typeof error.code === \"string\") {\n    return error.code;\n  }\n\n  return \"error\" in error &&\n    typeof error.error === \"object\" &&\n    error.error !== null &&\n    \"code\" in error.error &&\n    typeof error.error.code === \"string\"\n    ? error.error.code\n    : undefined;\n}\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _getRetryAfterHeader(error: any): string | null | undefined {\n  if (error?.headers) {\n    if (typeof error.headers.get === \"function\") {\n      return error.headers.get(\"retry-after\");\n    }\n    return error.headers[\"retry-after\"] ?? error.headers[\"Retry-After\"];\n  }\n\n  if (error?.response?.headers) {\n    if (typeof error.response.headers.get === \"function\") {\n      return error.response.headers.get(\"retry-after\");\n    }\n    return (\n      error.response.headers[\"retry-after\"] ??\n      error.response.headers[\"Retry-After\"]\n    );\n  }\n\n  return undefined;\n}\n\nfunction parseRetryAfterFromMessageMs(\n  message: string | undefined\n): number | undefined {\n  if (message == null) {\n    return undefined;\n  }\n\n  const match = RETRY_AFTER_MESSAGE_PATTERN.exec(message);\n  if (!match) {\n    return undefined;\n  }\n\n  const rawValue = Number(match[1]);\n  const unit = match[2]?.toLowerCase();\n  if (Number.isNaN(rawValue) || !unit) {\n    return undefined;\n  }\n\n  if (unit === \"ms\" || unit.startsWith(\"millisecond\")) {\n    return rawValue;\n  }\n\n  if (unit === \"m\" || unit.startsWith(\"min\")) {\n    return rawValue * 60_000;\n  }\n\n  if (unit === \"h\" || unit.startsWith(\"hr\") || unit.startsWith(\"hour\")) {\n    return rawValue * 3_600_000;\n  }\n\n  return rawValue * 1000;\n}\n\nfunction coerceError(error: unknown, fallbackMessage: string): Error {\n  if (error instanceof Error) {\n    return error;\n  }\n\n  const coerced = new Error(fallbackMessage);\n  if (typeof error === \"object\" && error !== null) {\n    Object.assign(coerced, error);\n  }\n  return coerced;\n}\n\nfunction setRateLimitMetadata(\n  error: unknown,\n  classification: RateLimitClassification\n) {\n  if (typeof error !== \"object\" || error === null) {\n    return;\n  }\n\n  const mutableError = error as Record<string, unknown>;\n  mutableError.rateLimitType = classification.action;\n  mutableError.rateLimitReason = classification.reason;\n\n  if (classification.retryAfterMs !== undefined) {\n    mutableError.retryAfterMs = classification.retryAfterMs;\n  }\n}\n\nexport function parseRetryAfterMs(\n  headerValue: string | null | undefined\n): number | undefined {\n  if (headerValue == null) {\n    return undefined;\n  }\n\n  const trimmed = headerValue.trim();\n  if (!trimmed) {\n    return undefined;\n  }\n\n  const seconds = Number(trimmed);\n  if (!Number.isNaN(seconds) && seconds >= 0) {\n    return seconds * 1000;\n  }\n\n  const date = Date.parse(trimmed);\n  if (!Number.isNaN(date)) {\n    const delayMs = date - Date.now();\n    return delayMs > 0 ? delayMs : 0;\n  }\n\n  return undefined;\n}\n\nexport function classifyRateLimitError(\n  error: unknown\n): RateLimitClassification | undefined {\n  const status = getResponseStatus(error) ?? getDirectStatus(error);\n  if (status !== 429) {\n    return undefined;\n  }\n\n  const code = getErrorCode(error);\n  if (code === \"insufficient_quota\") {\n    return { action: \"stop\", reason: \"insufficient_quota\" };\n  }\n\n  const message = getErrorMessage(error);\n  if (\n    message &&\n    QUOTA_EXHAUSTED_MESSAGE_PATTERNS.some((pattern) => pattern.test(message))\n  ) {\n    return { action: \"stop\", reason: \"quota_message\" };\n  }\n\n  const retryAfterMs =\n    parseRetryAfterMs(_getRetryAfterHeader(error)) ??\n    parseRetryAfterFromMessageMs(message);\n\n  if (retryAfterMs !== undefined) {\n    if (retryAfterMs <= RETRY_AFTER_AUTO_RETRY_THRESHOLD_MS) {\n      return {\n        action: \"wait\",\n        retryAfterMs,\n        reason: \"retry_after_hint\",\n      };\n    }\n\n    return {\n      action: \"capacity\",\n      retryAfterMs,\n      reason: \"retry_after_too_large\",\n    };\n  }\n\n  return { action: \"capacity\", reason: \"headerless_429\" };\n}\n\n/**\n * The default failed attempt handler for the AsyncCaller.\n * @param error - The error to handle.\n * @returns void\n */\nconst defaultFailedAttemptHandler = (error: unknown) => {\n  if (typeof error !== \"object\" || error === null) {\n    return;\n  }\n\n  // Honor a verdict already reached inside the callable, e.g. by a provider.\n  if (getRetryable(error) === false) {\n    throw error;\n  }\n\n  if (\n    (\"message\" in error &&\n      typeof error.message === \"string\" &&\n      (error.message.startsWith(\"Cancel\") ||\n        error.message.startsWith(\"AbortError\"))) ||\n    (\"name\" in error &&\n      typeof error.name === \"string\" &&\n      error.name === \"AbortError\")\n  ) {\n    // Deliberate cancellation, not a failure worth another attempt.\n    throw stampRetryable(error, false);\n  }\n  if (\n    \"code\" in error &&\n    typeof error.code === \"string\" &&\n    error.code === \"ECONNABORTED\"\n  ) {\n    throw error;\n  }\n  const status = getResponseStatus(error) ?? getDirectStatus(error);\n  if (status && STATUS_NO_RETRY.includes(+status)) {\n    // Deterministic client error; retrying it unchanged fails identically.\n    throw stampRetryable(error, false);\n  }\n\n  const code = getErrorCode(error);\n  if (code === \"insufficient_quota\") {\n    const err = coerceError(\n      error,\n      getErrorMessage(error) ?? \"Insufficient quota\"\n    );\n    err.name = \"InsufficientQuotaError\";\n    setRateLimitMetadata(err, {\n      action: \"stop\",\n      reason: \"insufficient_quota\",\n    });\n    // Exhausted quota needs an account action, not another attempt.\n    throw stampRetryable(err, false);\n  }\n\n  const rateLimitClassification = classifyRateLimitError(error);\n  if (rateLimitClassification) {\n    if (rateLimitClassification.action === \"wait\") {\n      setRateLimitMetadata(error, rateLimitClassification);\n      stampRetryable(error, true);\n      return;\n    }\n\n    const err = coerceError(\n      error,\n      getErrorMessage(error) ?? \"Rate limit exceeded\"\n    );\n    if (err.name === \"Error\") {\n      err.name =\n        rateLimitClassification.action === \"stop\"\n          ? \"RateLimitQuotaExhaustedError\"\n          : \"RateLimitCapacityError\";\n    }\n    setRateLimitMetadata(err, rateLimitClassification);\n    // Only \"stop\" is exhausted quota; \"capacity\" can still succeed later.\n    throw stampRetryable(err, rateLimitClassification.action !== \"stop\");\n  }\n};\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport type FailedAttemptHandler = (error: any) => any;\n\nexport interface AsyncCallerParams {\n  /**\n   * The maximum number of concurrent calls that can be made.\n   * Defaults to `Infinity`, which means no limit.\n   */\n  maxConcurrency?: number;\n  /**\n   * The maximum number of retries that can be made for a single call,\n   * with an exponential backoff between each attempt. Defaults to 6.\n   */\n  maxRetries?: number;\n  /**\n   * Custom handler to handle failed attempts. Takes the originally thrown\n   * error object as input, and should itself throw an error if the input\n   * error is not retryable.\n   */\n  onFailedAttempt?: FailedAttemptHandler;\n}\n\nexport interface AsyncCallerCallOptions {\n  signal?: AbortSignal;\n  maxRetries?: number;\n}\n\n/**\n * A class that can be used to make async calls with concurrency and retry logic.\n *\n * This is useful for making calls to any kind of \"expensive\" external resource,\n * be it because it's rate-limited, subject to network issues, etc.\n *\n * Concurrent calls are limited by the `maxConcurrency` parameter, which defaults\n * to `Infinity`. This means that by default, all calls will be made in parallel.\n *\n * Retries are limited by the `maxRetries` parameter, which defaults to 6. This\n * means that by default, each call will be retried up to 6 times, with an\n * exponential backoff between each attempt.\n */\nexport class AsyncCaller {\n  protected maxConcurrency: AsyncCallerParams[\"maxConcurrency\"];\n\n  protected maxRetries: AsyncCallerParams[\"maxRetries\"];\n\n  protected onFailedAttempt: AsyncCallerParams[\"onFailedAttempt\"];\n\n  private queue: (typeof import(\"p-queue\"))[\"default\"][\"prototype\"];\n\n  constructor(params: AsyncCallerParams) {\n    this.maxConcurrency = params.maxConcurrency ?? Infinity;\n    this.maxRetries = params.maxRetries ?? 6;\n    this.onFailedAttempt =\n      params.onFailedAttempt ?? defaultFailedAttemptHandler;\n\n    const PQueue = (\n      \"default\" in PQueueMod ? PQueueMod.default : PQueueMod\n    ) as typeof PQueueMod;\n    this.queue = new PQueue({ concurrency: this.maxConcurrency });\n  }\n\n  // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n  async call<A extends any[], T extends (...args: A) => Promise<any>>(\n    callable: T,\n    ...args: Parameters<T>\n  ): Promise<Awaited<ReturnType<T>>> {\n    return this.callWithRetries(this.maxRetries, callable, args);\n  }\n\n  private callWithRetries<\n    // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n    A extends any[],\n    // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n    T extends (...args: A) => Promise<any>,\n  >(\n    retries: AsyncCallerParams[\"maxRetries\"],\n    callable: T,\n    args: Parameters<T>\n  ): Promise<Awaited<ReturnType<T>>> {\n    return this.queue.add(\n      () =>\n        pRetry(\n          () =>\n            callable(...args).catch((error) => {\n              // oxlint-disable-next-line no-instanceof/no-instanceof\n              if (error instanceof Error) {\n                throw error;\n              } else {\n                throw new Error(error);\n              }\n            }),\n          {\n            onFailedAttempt: ({ error }) => this.onFailedAttempt?.(error),\n            retries,\n            randomize: true,\n            // If needed we can change some of the defaults here,\n            // but they're quite sensible.\n          }\n        ),\n      { throwOnTimeout: true }\n    );\n  }\n\n  // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n  callWithOptions<A extends any[], T extends (...args: A) => Promise<any>>(\n    options: AsyncCallerCallOptions,\n    callable: T,\n    ...args: Parameters<T>\n  ): Promise<Awaited<ReturnType<T>>> {\n    const retries = options.maxRetries ?? this.maxRetries;\n    // Note this doesn't cancel the underlying request,\n    // when available prefer to use the signal option of the underlying call\n    if (options.signal) {\n      let listener: (() => void) | undefined;\n      return Promise.race([\n        this.callWithRetries<A, T>(retries, callable, args),\n        new Promise<never>((_, reject) => {\n          listener = () => {\n            reject(getAbortSignalError(options.signal));\n          };\n          options.signal?.addEventListener(\"abort\", listener, { once: true });\n        }),\n      ]).finally(() => {\n        if (options.signal && listener) {\n          options.signal.removeEventListener(\"abort\", listener);\n        }\n      });\n    }\n    return this.callWithRetries<A, T>(retries, callable, args);\n  }\n\n  fetch(...args: Parameters<typeof fetch>): ReturnType<typeof fetch> {\n    return this.call(() =>\n      fetch(...args).then((res) => (res.ok ? res : Promise.reject(res)))\n    );\n  }\n}\n"],"mappings":";;;;;;;;;;;;;AAMA,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,sCAAsC;AAE5C,MAAM,mCAAmC;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,8BACJ;AAUF,SAAS,kBAAkB,OAAoC;CAC7D,OAAO,OAAO,UAAU,YACtB,UAAU,QACV,cAAc,SACd,OAAO,MAAM,aAAa,YAC1B,MAAM,aAAa,QACnB,YAAY,MAAM,YAClB,OAAO,MAAM,SAAS,WAAW,WAC/B,MAAM,SAAS,SACf,KAAA;AACN;AAEA,SAAS,gBAAgB,OAAoC;CAC3D,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC;CAGF,IAAI,YAAY,SAAS,OAAO,MAAM,WAAW,UAC/C,OAAO,MAAM;CAGf,IAAI,gBAAgB,SAAS,OAAO,MAAM,eAAe,UACvD,OAAO,MAAM;AAIjB;AAEA,SAAS,gBAAgB,OAAoC;CAC3D,OAAO,OAAO,UAAU,YACtB,UAAU,QACV,aAAa,SACb,OAAO,MAAM,YAAY,WACvB,MAAM,UACN,KAAA;AACN;AAEA,SAAS,aAAa,OAAoC;CACxD,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC;CAGF,IAAI,UAAU,SAAS,OAAO,MAAM,SAAS,UAC3C,OAAO,MAAM;CAGf,OAAO,WAAW,SAChB,OAAO,MAAM,UAAU,YACvB,MAAM,UAAU,QAChB,UAAU,MAAM,SAChB,OAAO,MAAM,MAAM,SAAS,WAC1B,MAAM,MAAM,OACZ,KAAA;AACN;AAGA,SAAS,qBAAqB,OAAuC;CACnE,IAAI,OAAO,SAAS;EAClB,IAAI,OAAO,MAAM,QAAQ,QAAQ,YAC/B,OAAO,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