eca icon indicating copy to clipboard operation
eca copied to clipboard

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

Open zikajk opened this issue 10 months ago • 2 comments

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.

zikajk avatar Jan 26 '26 16:01 zikajk

It started to happen quite often. Or I assume this problem is related -> I can't do eca-stop so I need to kill the java process and /resume the chat to continue.

zikajk avatar Jan 30 '26 06:01 zikajk

Yeah we need to fix this blocking thing in each LLM impl and do carefully

ericdallo avatar Feb 02 '26 12:02 ericdallo