Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancelling a streaming chatbot return an error in the browser console #10648

Open
1 task done
GuizMeuh opened this issue Feb 21, 2025 · 1 comment
Open
1 task done
Labels
bug Something isn't working

Comments

@GuizMeuh
Copy link

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

@GuizMeuh GuizMeuh added the bug Something isn't working label Feb 21, 2025
@ngaudemet
Copy link

Same pb here, thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants