QuantumNous/new-api · warning · Error

Delete failed

Error message

Delete failed

What it means

Thrown by deleteStaleInstanceMutation when deleteStaleSystemInstance(nodeName) rejects or returns success=false. The message is a fallback; the server's res.message wins when present. onError additionally re-invalidates the instances query so the table reflects true state.

Source

Thrown at web/src/features/system-info/components/system-instances-panel.tsx:530

  const instances = instancesQuery.data ?? []
  const staleInstances = instances.filter(
    (instance) => instance.status === 'stale'
  )
  const hasStaleInstances = staleInstances.length > 0
  const loading = instancesQuery.isLoading
  const refreshing = instancesQuery.isFetching && !instancesQuery.isLoading

  const invalidateInstances = async () => {
    await queryClient.invalidateQueries({
      queryKey: ['system-info', 'instances'],
    })
  }

  const deleteStaleInstanceMutation = useMutation({
    mutationFn: async (nodeName: string) => {
      const res = await deleteStaleSystemInstance(nodeName)
      if (!res.success) {
        throw new Error(res.message || t('Delete failed'))
      }
      return res
    },
    onMutate: (nodeName) => {
      setDeletingNodeName(nodeName)
    },
    onSuccess: async () => {
      toast.success(t('Deleted stale instance'))
      await invalidateInstances()
      setDeleteTarget(null)
    },
    onError: (error) => {
      toast.error(error instanceof Error ? error.message : t('Delete failed'))
      void invalidateInstances()
    },
    onSettled: () => {
      setDeletingNodeName(null)
    },

View on GitHub (pinned to e2c7aa7b10)

Solutions

  1. Read the server's message in the failed request's response body; it distinguishes 'not found' from permission or DB errors.
  2. If the node rejoined, let the poll refresh; the row will stop being stale and no delete is needed.
  3. Confirm the account has admin permission for instance management endpoints.
  4. Retry after the automatic invalidation refreshes the list, deleting only rows still marked stale.
Defensive patterns

Strategy: try-catch

Try / catch

onError: (error) => {
  toast.error(error instanceof Error ? error.message : t('Delete failed'))
  void invalidateInstances() // resync UI with true server state
}

Prevention

When it happens

Trigger: DELETE of a stale instance by nodeName where the node name does not exist (already cleaned by another admin or by node rejoin), the instance is no longer stale (heartbeats resumed between load and click), non-admin token, or backend error while removing the node's record.

Common situations: Two admins cleaning stale nodes concurrently; a flapping node that goes stale then rejoins; permission mismatch between the frontend page and the backend route guard; database error during delete.

Related errors


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