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
- Confirm the check-in feature is fully enabled in system settings (server side), not just the client flag
- Refresh/re-login to rule out session expiry, then let react-query refetch
- Call the checkin status endpoint with the same month parameter and read the message field
- 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
- Gate the query on both checkinEnabled and a valid month format
- Give the query a bounded retry (1) for transient backend blips
- Render react-query's error state in the card instead of swallowing it
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
- Failed to load login sessions
- Failed to fetch usage
- Failed to fetch channel key
- Failed to start Telegram binding
- Failed to update settings
AI-assisted analysis of QuantumNous/new-api@e2c7aa7b10 (2026-08-15).
Data as JSON: /api/errors/5bc705195fe510e7.
Report an issue: GitHub.