QuantumNous/new-api · error · Error

Failed to fetch checkin status

Error message

Failed to fetch checkin status

What it means

Thrown inside the react-query queryFn of the checkin calendar card when getCheckinStatus(currentMonthStr) resolves with success=false or missing data. The query runs only when checkinEnabled, keyed by month string, with a 30s staleTime; the thrown message feeds react-query's error state.

Source

Thrown at web/src/features/profile/components/checkin-calendar-card.tsx:92

    const y = currentMonth.getFullYear()
    const m = String(currentMonth.getMonth() + 1).padStart(2, '0')
    return `${y}-${m}`
  }, [currentMonth])

  // Fetch checkin status
  /* eslint-disable @tanstack/query/exhaustive-deps */
  const {
    data: checkinData,
    isLoading,
    refetch,
  } = useQuery({
    queryKey: ['checkin-status', currentMonthStr],
    queryFn: async () => {
      const res = await getCheckinStatus(currentMonthStr)
      if (res.success && res.data) {
        return res.data
      }
      throw new Error(res.message || t('Failed to fetch checkin status'))
    },
    enabled: checkinEnabled,
    staleTime: 30000,
  })
  /* eslint-enable @tanstack/query/exhaustive-deps */

  const checkinRecordsMap = useMemo(() => {
    const map: Record<string, number> = {}
    const records = checkinData?.stats?.records || []
    records.forEach((record: CheckinRecord) => {
      map[record.checkin_date] = record.quota_awarded
    })
    return map
  }, [checkinData?.stats?.records])

  const monthlyQuota = useMemo(() => {
    const records = checkinData?.stats?.records || []
    return records.reduce(

View on GitHub (pinned to e2c7aa7b10)

Solutions

  1. Confirm the check-in feature is fully enabled in system settings (server side), not just the client flag
  2. Refresh/re-login to rule out session expiry, then let react-query refetch
  3. Call the checkin status endpoint with the same month parameter and read the message field
  4. Check backend logs for the checkin route at request time (route missing vs internal error)

Example fix

// before
const res = await getCheckinStatus(currentMonthStr)
if (res.success && res.data) {
  return res.data
}
throw new Error(res.message || t('Failed to fetch checkin status'))
// after - add a retry for transient failures
const res = await getCheckinStatus(currentMonthStr)
if (res.success && res.data) {
  return res.data
}
throw new Error(res.message || t('Failed to fetch checkin status'))
// queryClient option: { retry: 1, refetchOnWindowFocus: false }
Defensive patterns

Strategy: try-catch

Validate before calling

const isValidMonth = /^\d{4}-\d{2}$/.test(currentMonthStr)
// build query with enabled: checkinEnabled && isValidMonth

Try / catch

// inside queryFn
const res = await getCheckinStatus(currentMonthStr)
if (res.success && res.data) return res.data
throw new Error(res.message || t('Failed to fetch checkin status'))
// consumers read { data, isLoading, error } from useQuery

Prevention

When it happens

Trigger: Mounting the profile page with check-in enabled while the backend reports failure for the month status (check-in feature misconfigured, invalid month param) or the request rejects (401 session, network).

Common situations: Check-in feature flag half-enabled server-side; user session expired so /api/user/checkin returns 401; month string computed at midnight boundary mismatching backend expectations; backend deploy missing the checkin route.

Related errors


AI-assisted analysis of QuantumNous/new-api@e2c7aa7b10 (2026-08-15). Data as JSON: /api/errors/5bc705195fe510e7. Report an issue: GitHub.