Repository: stable-diffusion-webui
Issue: [Bug]: Occasional error message in console
Labels: bug-report

### Is there an existing issue for this?

- [X] I have searched the existing issues and checked the recent builds/commits

### What happened?

**This is a copy paste from the command prompt of an error message that I occasionally get while generating images or during inpaint:**

ERROR:asyncio:Exception in callback H11Protocol.timeout_keep_alive_handler()
handle: <TimerHandle when=84064.687 H11Protocol.timeout_keep_alive_handler()>
Traceback (most recent call last):
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\h11_state.py", line 249, in _fire_event_triggered_transitions
new_state = EVENT_TRIGGERED_TRANSITIONS[role][state][event_type]
KeyError: <class 'h11._events.ConnectionClosed'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "asyncio\events.py", line 80, in _run
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 363, in timeout_keep_alive_handler
self.conn.send(event)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\h11_connection.py", line 468, in send
data_list = self.send_with_data_passthrough(event)
File "C:\Users\XXXX\d.webui\system\python\lib\site-packages\h11_connection.py", line 493, in send_with_data_passthrough
self._process_event(self.our_role, event)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\h11_connection.py", line 242, in _process_event
self._cstate.process_event(role, type(event), server_switch_event)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\h11_state.py", line 238, in process_event
self._fire_event_triggered_transitions(role, event_type)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\h11_state.py", line 251, in _fire_event_triggered_transitions
raise LocalProtocolError(
h11._util.LocalProtocolError: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
*** API error: POST: http://127.0.0.1:7860/api/predict {'error': 'LocalProtocolError', 'detail': '', 'body': '', 'errors': "Can't send data when our state is ERROR"}
Traceback (most recent call last):
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\middleware\errors.py", line 162, in call
await self.app(scope, receive, _send)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\middleware\base.py", line 109, in call
await response(scope, receive, send)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\responses.py", line 270, in call
async with anyio.create_task_group() as task_group:
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\anyio_backends_asyncio.py", line 597, in aexit
raise exceptions[0]
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\responses.py", line 273, in wrap await func()
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\middleware\base.py", line 134, in stream_response
return await super().stream_response(send)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\responses.py", line 255, in stream_response
await send(
File "C:\Users\OXXXX\sd.webui\system\python\lib\site-packages\starlette\middleware\errors.py", line 159, in _send
await send(message)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 490, in send
output = self.conn.send(event=response)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\h11_connection.py", line 468, in send
data_list = self.send_with_data_passthrough(event)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\h11_connection.py", line 483, in send_with_data_passthrough
raise LocalProtocolError("Can't send data when our state is ERROR")
h11._util.LocalProtocolError: Can't send data when our state is ERROR

ERROR: Exception in ASGI application
Traceback (most recent call last):
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 408, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 84, in call
return await self.app(scope, receive, send)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\fastapi\applications.py", line 273, in call
await super().call(scope, receive, send)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\applications.py", line 122, in call
await self.middleware_stack(scope, receive, send)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\middleware\errors.py", line 184, in call
raise exc
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\middleware\errors.py", line 162, in call
await self.app(scope, receive, _send)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\middleware\base.py", line 109, in call
await response(scope, receive, send)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\responses.py", line 270, in call async with anyio.create_task_group() as task_group:
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\anyio_backends_asyncio.py", line 597, in aexit
raise exceptions[0]
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\responses.py", line 273, in wrap
await func()
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\middleware\base.py", line 134, in stream_response
return await super().stream_response(send)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\responses.py", line 255, in stream_response
await send(
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\middleware\errors.py", line 159, in _send
await send(message)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 490, in send
output = self.conn.send(event=response)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\h11_connection.py", line 468, in send
data_list = self.send_with_data_passthrough(event)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\h11_connection.py", line 483, in send_with_data_passthrough
raise LocalProtocolError("Can't send data when our state is ERROR")
h11._util.LocalProtocolError: Can't send data when our state is ERROR
'AsyncRequest' object has no attribute '_json_response_data'
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='qzhihrlr8q_805' coro=<Queue.process_events() done, defined at C:\XXXX\sd.webui\system\python\lib\site-packages\gradio\queueing.py:384> exception=ValueError('[<gradio.queueing.Event object at 0x0000023CF1178100>] is not in list')>
Traceback (most recent call last):
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\gradio\queueing.py", line 471, in process_events
self.active_jobs[self.active_jobs.index(events)] = None
ValueError: [<gradio.queueing.Event object at 0x0000023CF1178100>] is not in list "

**It seems very random, I'm not sure what is triggering it. Sometimes it comes up during first geberation, other times it can run a long time before it appears. It didn't use to be like that always, but something triggered it. If anyone has any ideas please help. Thanks.**

### Steps to reproduce the problem

It's random. Can't reproduce it.


### What should have happened?

IT shouldgenerate a file/image.

### Sysinfo

.

### What browsers do you use to access the UI ?

Mozilla Firefox

### Console logs

```Shell
ERROR:asyncio:Exception in callback H11Protocol.timeout_keep_alive_handler()
handle: <TimerHandle when=84064.687 H11Protocol.timeout_keep_alive_handler()>
Traceback (most recent call last):
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\h11_state.py", line 249, in _fire_event_triggered_transitions
new_state = EVENT_TRIGGERED_TRANSITIONS[role][state][event_type]
KeyError: <class 'h11._events.ConnectionClosed'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "asyncio\events.py", line 80, in _run
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 363, in timeout_keep_alive_handler
self.conn.send(event)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\h11_connection.py", line 468, in send
data_list = self.send_with_data_passthrough(event)
File "C:\Users\XXXX\d.webui\system\python\lib\site-packages\h11_connection.py", line 493, in send_with_data_passthrough
self._process_event(self.our_role, event)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\h11_connection.py", line 242, in _process_event
self._cstate.process_event(role, type(event), server_switch_event)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\h11_state.py", line 238, in process_event
self._fire_event_triggered_transitions(role, event_type)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\h11_state.py", line 251, in _fire_event_triggered_transitions
raise LocalProtocolError(
h11._util.LocalProtocolError: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
*** API error: POST: http://127.0.0.1:7860/api/predict {'error': 'LocalProtocolError', 'detail': '', 'body': '', 'errors': "Can't send data when our state is ERROR"}
Traceback (most recent call last):
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\middleware\errors.py", line 162, in call
await self.app(scope, receive, _send)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\middleware\base.py", line 109, in call
await response(scope, receive, send)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\responses.py", line 270, in call
async with anyio.create_task_group() as task_group:
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\anyio_backends_asyncio.py", line 597, in aexit
raise exceptions[0]
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\responses.py", line 273, in wrap await func()
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\middleware\base.py", line 134, in stream_response
return await super().stream_response(send)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\responses.py", line 255, in stream_response
await send(
File "C:\Users\OXXXX\sd.webui\system\python\lib\site-packages\starlette\middleware\errors.py", line 159, in _send
await send(message)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 490, in send
output = self.conn.send(event=response)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\h11_connection.py", line 468, in send
data_list = self.send_with_data_passthrough(event)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\h11_connection.py", line 483, in send_with_data_passthrough
raise LocalProtocolError("Can't send data when our state is ERROR")
h11._util.LocalProtocolError: Can't send data when our state is ERROR

ERROR: Exception in ASGI application
Traceback (most recent call last):
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 408, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 84, in call
return await self.app(scope, receive, send)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\fastapi\applications.py", line 273, in call
await super().call(scope, receive, send)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\applications.py", line 122, in call
await self.middleware_stack(scope, receive, send)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\middleware\errors.py", line 184, in call
raise exc
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\middleware\errors.py", line 162, in call
await self.app(scope, receive, _send)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\middleware\base.py", line 109, in call
await response(scope, receive, send)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\responses.py", line 270, in call async with anyio.create_task_group() as task_group:
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\anyio_backends_asyncio.py", line 597, in aexit
raise exceptions[0]
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\responses.py", line 273, in wrap
await func()
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\middleware\base.py", line 134, in stream_response
return await super().stream_response(send)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\responses.py", line 255, in stream_response
await send(
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\starlette\middleware\errors.py", line 159, in _send
await send(message)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 490, in send
output = self.conn.send(event=response)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\h11_connection.py", line 468, in send
data_list = self.send_with_data_passthrough(event)
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\h11_connection.py", line 483, in send_with_data_passthrough
raise LocalProtocolError("Can't send data when our state is ERROR")
h11._util.LocalProtocolError: Can't send data when our state is ERROR
'AsyncRequest' object has no attribute '_json_response_data'
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='qzhihrlr8q_805' coro=<Queue.process_events() done, defined at C:\XXXX\sd.webui\system\python\lib\site-packages\gradio\queueing.py:384> exception=ValueError('[<gradio.queueing.Event object at 0x0000023CF1178100>] is not in list')>
Traceback (most recent call last):
File "C:\Users\XXXX\sd.webui\system\python\lib\site-packages\gradio\queueing.py", line 471, in process_events
self.active_jobs[self.active_jobs.index(events)] = None
ValueError: [<gradio.queueing.Event object at 0x0000023CF1178100>] is not in list "
```


### Additional information

.