Skip to content

Chat hangs on "Waiting model" when LLM stream stalls - STOP cannot interrupt blocked I/O #279

@zikajk

Description

@zikajk

To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.

This ticket has been created by ECA. There is currently no known way how to reproduce this bug. It just randomly appears (with no error) so I asked Claude to find out what is going on ;-)

Describe the bug
When an LLM provider's streaming response stalls (server keeps connection open but stops sending data), the chat gets
stuck on "Waiting model" indefinitely. Clicking STOP does not recover the chat. Attempting to shut down ECA also
fails with "Timeout while waiting for response. Method: shutdown".

Root cause: .readLine() on the response InputStream blocks forever. STOP sets a :stopping flag, but this flag is only
checked in callbacks that fire after .readLine() returns. Since it never returns, the flag is never checked.
Thread.interrupt() does not work on blocking java.io streams.

Affects all streaming providers (openai_chat, anthropic, ollama, openai).

To Reproduce (not sure if possible)
Steps to reproduce the behavior:

  1. Start a chat with any streaming LLM provider
  2. Send a message
  3. Have the LLM server stall mid-stream (keep connection open, stop sending data)
  4. Observe chat stuck on "Waiting model"
  5. Click STOP - chat remains stuck
  6. Try to stop ECA - get "Timeout while waiting for response. Method: shutdown"

Expected behavior

  • Clicking STOP should immediately cancel the request and return chat to idle state, allowing new messages to be sent.
  • There should be some timeout (180s?) on streaming response

Additional context
Proposed fix: Store the response InputStream when streaming starts, close it when STOP is pressed. Closing the stream
causes .readLine() to throw IOException, which is already handled via on-error.

Implementation:

  1. Add cancel-stream* atom to callbacks, store in chat state
  2. Each provider stores body (InputStream) in the atom before reading
  3. prompt-stop closes the stream via the atom

~10 lines across chat.clj, llm_api.clj, and each provider file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions