Crosstalk-Solutions/project-nomad · error

Failed to delete all sessions

Error message

Failed to delete all sessions

What it means

Generic 500 from ChatsController.destroyAll when chatService.deleteAllSessions() throws. All session/message deletion happens in the service layer; any DB error surfaces here as a generic failure message.

Source

Thrown at admin/app/controllers/chats_controller.ts:115

      const sessionId = parseInt(params.id)
      const data = await request.validateUsing(addMessageSchema)
      const message = await this.chatService.addMessage(sessionId, data.role, data.content)
      return response.status(201).json(message)
    } catch (error) {
      logger.error({ err: error }, '[ChatsController] Failed to add message')
      return response.status(500).json({
        error: 'Failed to add message',
      })
    }
  }

  async destroyAll({ response }: HttpContext) {
    try {
      const result = await this.chatService.deleteAllSessions()
      return response.status(200).json(result)
    } catch (error) {
      logger.error({ err: error }, '[ChatsController] Failed to delete all sessions')
      return response.status(500).json({
        error: 'Failed to delete all sessions',
      })
    }
  }
}

View on GitHub (pinned to 0bd1c6f4f9)

Solutions

  1. Inspect logs for the logged err to find the root cause
  2. Verify DB write permissions and that no other process holds a write lock
  3. If FK constraints fail, delete child rows (messages) before sessions or enable cascade deletes
Defensive patterns

Strategy: try-catch

Try / catch

try { await api.deleteAllSessions() } catch (e) { if (e.status === 500) alert('DB busy — try again'); throw e }

Prevention

When it happens

Trigger: DELETE request to the chats collection endpoint while the database is unavailable, locked, or a FK constraint prevents bulk deletion.

Common situations: Concurrent chat activity holding write locks, read-only database mounts, or a partially-applied migration missing the tables being deleted.

Related errors


AI-assisted analysis of Crosstalk-Solutions/project-nomad@0bd1c6f4f9 (2026-08-27). Data as JSON: /api/errors/ccfd3bb75707b929. Report an issue: GitHub.