linshenkx/prompt-optimizer · error · Error

${context}: ${(error as Error).message || String(error)}

Error message

${context}: ${(error as Error).message || String(error)}

What it means

Thrown from the retry loop for Google Drive downloads when a fetch-level error occurs (network failure, abort, CORS) that is deemed retryable, but the retry budget is already exhausted. The original error is preserved as cause and its message is prefixed with the operation context.

Source

Thrown at packages/ui/src/utils/remote-backup.ts:575

  context: string,
  options?: { returnAuthFailures?: boolean },
): Promise<Response> => {
  let lastError: unknown

  for (let attempt = 1; attempt <= GOOGLE_DRIVE_DOWNLOAD_RETRY_ATTEMPTS; attempt += 1) {
    try {
      const response = await fetch(url, init)
      if (response.ok) return response
      if (options?.returnAuthFailures && isGoogleAuthStatus(response.status)) {
        return response
      }
      if (!isRetryableHttpStatus(response.status) || attempt === GOOGLE_DRIVE_DOWNLOAD_RETRY_ATTEMPTS) {
        return assertOkResponse(response, context)
      }
      lastError = new Error(`${context}: ${response.status} ${response.statusText}`)
    } catch (error) {
      if (!isRetryableFetchError(error) || attempt === GOOGLE_DRIVE_DOWNLOAD_RETRY_ATTEMPTS) {
        throw new Error(`${context}: ${(error as Error).message || String(error)}`, { cause: error })
      }
      lastError = error
    }

    await sleep(GOOGLE_DRIVE_DOWNLOAD_RETRY_BASE_DELAY_MS * attempt)
  }

  throw new Error(`${context}: ${(lastError as Error)?.message || String(lastError)}`)
}

export const joinRemotePath = (...parts: string[]): string =>
  parts
    .map((part) => part.replace(/^\/+|\/+$/g, ''))
    .filter(Boolean)
    .join('/')

const normalizeObjectPath = (path: string): string => joinRemotePath(path)

View on GitHub (pinned to 3e677b1d9f)

Solutions

  1. Check error.cause for the underlying network error and address it (DNS, proxy, TLS, offline state)
  2. Verify network connectivity to the backup provider endpoints (curl/fetch manually)
  3. Increase retry attempts/backoff for genuinely flaky connections via module constants if configurable
  4. If a proxy intercepts requests, configure it to allow the Google API domains or route downloads server-side
Defensive patterns

Strategy: retry

Validate before calling

if (!navigator.onLine) {
  // defer backup download until online
}

Try / catch

try {
  const data = await downloadRemoteBackup(...)
} catch (error) {
  const cause = (error as Error).cause
  if (cause instanceof TypeError) {
    // network-level failure: check connectivity/proxy, retry with longer backoff
    await waitForOnline()
    return downloadRemoteBackup(...)
  }
  throw error
}

Prevention

When it happens

Trigger: Transient network errors persisting across all retry attempts (offline machine, DNS failure, proxy blocking fetch to googleapis.com, aborted requests); the last attempt throws a retryable fetch error when attempt === GOOGLE_DRIVE_DOWNLOAD_RETRY_ATTEMPTS, forcing this immediate rethrow.

Common situations: Corporate proxy/SSL inspection breaking fetch to Google endpoints; flaky connectivity during large backup downloads; browser offline mode; CORS misconfiguration persisting across retries (non-transient but classified retryable).

Related errors


AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27). Data as JSON: /api/errors/54034e5f75d72286. Report an issue: GitHub.