chatboxai/chatbox · error · ApiError

No refresh token available

Error message

No refresh token available

What it means

Error "No refresh token available" thrown in chatboxai/chatbox.

Source

Thrown at src/shared/request/request.ts:261

    let requestError: BaseError | null = null
    const retry = options.retry || 0

    for (let i = 0; i < retry + 1; i++) {
      try {
        const res = await fetch(url, init)

        // 检查 401 Unauthorized
        if (res.status === 401) {
          console.debug('🔄 Access token expired, refreshing...')

          // 防止并发刷新:如果已有刷新请求,等待它完成
          if (!refreshPromise) {
            refreshPromise = (async () => {
              try {
                const currentTokens = await getTokens()
                if (!currentTokens) {
                  throw new ApiError('No refresh token available')
                }

                console.debug('🔑 Refreshing access token with refresh token...')
                const newTokens = await refreshTokens(currentTokens.refreshToken)
                console.debug('✅ Token refreshed successfully')
                return newTokens
              } catch (error) {
                console.error('❌ Failed to refresh token:', error)
                // 刷新失败,清除所有 tokens
                await clearTokens()
                throw new ApiError('Token refresh failed, please login again')
              } finally {
                refreshPromise = null
              }
            })()
          }

          // 等待刷新完成

View on GitHub (pinned to 81571269ad)

Solutions

  1. Sign in again; tokens were cleared between the 401 response and the refresh attempt.
  2. Investigate why getTokens() returned null mid-request (concurrent logout or storage failure).

Example fix

const currentTokens = await getTokens()
if (!currentTokens) {
  // Session was logged out concurrently; prompt re-login
}

When it happens

Trigger: Thrown at src/shared/request/request.ts:261 when the library encounters an invalid state.

Common situations: Occurs in src/shared/request/request.ts when a token refresh is attempted but no refresh token is stored; the user must log in again.


AI-assisted analysis of chatboxai/chatbox@81571269ad (2026-08-12). Data as JSON: /api/errors/5872110b4a0e1500. Report an issue: GitHub.