private shouldRetry()

in core.ts [679:700]


  private shouldRetry(response: Response): boolean {
    // Note this is not a standard header.
    const shouldRetryHeader = response.headers.get("x-should-retry");

    // If the server explicitly says whether or not to retry, obey.
    if (shouldRetryHeader === "true") return true;
    if (shouldRetryHeader === "false") return false;

    // Retry on request timeouts.
    if (response.status === 408) return true;

    // Retry on lock timeouts.
    if (response.status === 409) return true;

    // Retry on rate limits.
    if (response.status === 429) return true;

    // Retry internal errors.
    if (response.status >= 500) return true;

    return false;
  }