QuantumNous/new-api · warning · Error

We could not load system tasks.

Error message

We could not load system tasks.

What it means

Thrown by the SystemTasksPanel queryFn when listSystemTasks(TASK_LIMIT) rejects or returns success=false / non-array data. With retry:false the panel immediately shows its error state with this message; polling restarts only when the query refetches.

Source

Thrown at web/src/features/system-info/components/system-tasks-panel.tsx:214

                  {task.error || '-'}
                </TableCell>
              </TableRow>
            )
          })}
        </TableBody>
      </Table>
    </div>
  )
}

export function SystemTasksPanel() {
  const { t } = useTranslation()
  const tasksQuery = useQuery({
    queryKey: ['system-info', 'system-tasks'],
    queryFn: async () => {
      const res = await listSystemTasks(TASK_LIMIT)
      if (!res.success || !Array.isArray(res.data)) {
        throw new Error(res.message || t('We could not load system tasks.'))
      }
      return res.data
    },
    staleTime: 30 * 1000,
    retry: false,
    refetchInterval: (query) =>
      query.state.data?.some((task) => isActiveStatus(task.status))
        ? ACTIVE_POLL_INTERVAL_MS
        : false,
  })

  const tasks = tasksQuery.data ?? []
  const loading = tasksQuery.isLoading
  const refreshing = tasksQuery.isFetching && !tasksQuery.isLoading
  const hasActiveTasks = tasks.some((task) => isActiveStatus(task.status))
  const activeTasks = tasks.filter((task) => isActiveStatus(task.status))
  const historyTasks = tasks.filter((task) => !isActiveStatus(task.status))

View on GitHub (pinned to e2c7aa7b10)

Solutions

  1. Verify the caller is an admin; the system-tasks endpoint is privileged.
  2. Inspect the raw response: if data is not an array, the frontend service and backend contract have diverged — align listSystemTasks with the actual response shape.
  3. Check backend logs/migrations for the system tasks table if the handler errors.
  4. For transient failures, refetch manually or wait for the conditional poll to resume.
Defensive patterns

Strategy: validation

Type guard

function isTaskList(data: unknown): data is SystemTask[] {
  return Array.isArray(data) && data.every(
    (t): t is SystemTask =>
      typeof t === 'object' && t !== null && typeof (t as SystemTask).status === 'string'
  )
}

Try / catch

queryFn: async () => {
  const res = await listSystemTasks(TASK_LIMIT)
  if (!res.success || !Array.isArray(res.data)) {
    throw new Error(res.message || t('We could not load system tasks.'))
  }
  return res.data
},
retry: false,

Prevention

When it happens

Trigger: GET of the system-tasks list fails: non-admin caller, backend task registry error, type mismatch where data is an object (e.g. paginated envelope) rather than the expected array, or network/backend outage.

Common situations: Non-admin opens system info; backend version skew where the endpoint returns {data:{items:[...]}} instead of a bare array; task store (DB table) missing after a failed migration; proxy 502 during deploy.

Related errors


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