Open
Description
Describe the bug
Hi team !
When stopping a streaming chatbot with a stop button, it returns the error : "Unexpected error Connection errored out."
Is this an expected behaviour ?
Have you searched existing issues? 🔎
- I have searched and found no existing issues
Reproduction
import gradio as gr
from gradio import ChatMessage
import asyncio
async def stream(conversation):
for i in range(1000):
conversation.append(ChatMessage(role="assistant", content=f"{i}"))
await asyncio.sleep(1)
yield conversation
def show_stop():
return gr.update(submit_btn=False, stop_btn=True)
def hide_stop():
return gr.update(submit_btn=True, stop_btn=False)
def stop(chat):
return gr.update(submit_btn=True, stop_btn=False), chat
with gr.Blocks() as test_io:
with gr.Column():
conversation = gr.Chatbot(label="Conversation", type="messages")
input_text = gr.Textbox(lines=1, placeholder="Type here", show_label=False, submit_btn=True, stop_btn=False, interactive=True)
question_run = (
gr.on(triggers=[input_text.submit],fn=show_stop, outputs=input_text, queue=False)
.then(fn=stream,inputs=conversation, outputs=conversation)
)
question_run.then(fn=hide_stop, outputs=input_text, queue=False)
input_text.stop(fn=stop,inputs=conversation, outputs=[input_text, conversation], cancels=[question_run], queue=False)
test_io.queue(default_concurrency_limit=10)
test_io.launch()
Screenshot
No response
Logs
In the browser console (Chrome):
submit.ts:635 Unexpected error Connection errored out.
$t @ submit.ts:635
(anonymous) @ stream.ts:81
E_.s.onerror @ stream.ts:80
(anonymous) @ stream.ts:217
System Info
Gradio Environment Information:
------------------------------
Operating System: Windows
gradio version: 5.14.0
gradio_client version: 1.7.0
------------------------------------------------
gradio dependencies in your environment:
aiofiles: 23.2.1
anyio: 4.6.2.post1
audioop-lts is not installed.
fastapi: 0.115.2
ffmpy: 0.3.1
gradio-client==1.7.0 is not installed.
httpx: 0.27.2
huggingface-hub: 0.25.2
jinja2: 3.1.3
markupsafe: 2.1.4
numpy: 1.26.4
orjson: 3.10.11
packaging: 24.2
pandas: 2.2.0
pillow: 10.2.0
pydantic: 2.10.3
pydub: 0.25.1
python-multipart: 0.0.19
pyyaml: 6.0.2
ruff: 0.9.4
safehttpx: 0.1.6
semantic-version: 2.10.0
starlette: 0.40.0
tomlkit: 0.12.0
typer: 0.12.3
typing-extensions: 4.12.2
urllib3: 2.2.3
uvicorn: 0.27.0
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.
gradio_client dependencies in your environment:
fsspec: 2023.12.2
httpx: 0.27.2
huggingface-hub: 0.25.2
packaging: 24.2
typing-extensions: 4.12.2
websockets: 11.0.3
Severity
I can work around it