Skip to content

AI chat session gets stuck in processing state after server restart #4260

@elias-ba

Description

@elias-ba

Description

When the server restarts while an AI message is being processed, the session gets permanently stuck showing the "..." loading indicator with no way to recover. Users must create a new session to continue.

Steps to Reproduce

  1. Open an AI chat session
  2. Send a message to the AI
  3. While the AI is processing (showing "..."), restart the server
  4. Reconnect/refresh the page
  5. The session shows "..." forever with no way to cancel or send another message

Root Cause

  1. When server restarts mid-processing, the message remains in DB with status: :processing
  2. On reconnect, frontend loads this status via channel join and sets isLoading = true
  3. No recovery mechanism exists to detect orphaned processing messages

Why This Is Tricky

We can't simply "auto-fail messages in processing state on join" because in collaborative sessions, another user might have legitimately sent a message that's actively being processed.

Potential Solutions

Option 1: Time-based recovery

Add a background job that marks messages as :error if stuck in :processing for > 5 minutes:

  • Check inserted_at or add processing_started_at timestamp
  • Run periodic Oban job to clean up orphaned messages

Option 2: Verify Oban job exists

On session load, check if the Oban job for processing messages actually exists in the queue. If not, the message is orphaned and should be failed.

Option 3: Client-side timeout warning

After X minutes of :processing status, show a warning with a "Retry" or "Cancel" button.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugNewly identified bug

    Type

    No type

    Projects

    Status

    Tech Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions