Repository: stable-diffusion-webui
Issue: [Bug]:  The --api execution argument causes an asyncio:Exception in callback H11Protocol.timeout_keep_alive_handler() error.
Labels: bug-report

### Checklist

- [ ] The issue exists after disabling all extensions
- [X] The issue exists on a clean installation of webui
- [ ] The issue is caused by an extension, but I believe it is caused by a bug in the webui
- [X] The issue exists in the current version of the webui
- [ ] The issue has not been reported before recently
- [X] The issue has been reported before but has not been fixed yet

### What happened?

An error occurs when creating an image in the NON906/sd-webui-chatgpt extension.

### Steps to reproduce the problem

1. install extension form https://github.com/NON906/sd-webui-chatgpt.git
2. Add or modify the items in the txtimg field below and click the Save and Reflect button.
     "enable_hr": true,
     "denoising_strength": 0.5;
     "hr_scale": 1.5;
     "hr_steps": 20,
     "hr_upscaler": "Latent",
3. In sd-webui-chatgpt tab  type "raccoon" in textbox and press chat
4. If step 3 was normal, retry step 3.

### What should have happened?

An image must be drawn for each request.

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

_No response_

### Sysinfo

[sysinfo-2024-01-12-14-03.json](https://github.com/AUTOMATIC1111/stable-diffusion-webui/files/13919869/sysinfo-2024-01-12-14-03.json)


### Console logs

```Shell
5%|████▏ | 1/20 [00:00<00:04, 4.05it/s]ERROR:asyncio:Exception in callback H11Protocol.timeout_keep_alive_handler()
handle: <TimerHandle when=6623.296 H11Protocol.timeout_keep_alive_handler()>
Traceback (most recent call last):
File "C:\Users\smbae\AppData\Local\Programs\Python\Python310\lib\asyncio\events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "F:\stable-diffusion-webui\venv\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 363, in timeout_keep_alive_handler
self.conn.send(event)
File "F:\stable-diffusion-webui\venv\lib\site-packages\h11_connection.py", line 512, in send
data_list = self.send_with_data_passthrough(event)
File "F:\stable-diffusion-webui\venv\lib\site-packages\h11_connection.py", line 537, in send_with_data_passthrough
self._process_event(self.our_role, event)
File "F:\stable-diffusion-webui\venv\lib\site-packages\h11_connection.py", line 272, in _process_event
self._cstate.process_event(role, type(event), server_switch_event)
File "F:\stable-diffusion-webui\venv\lib\site-packages\h11_state.py", line 293, in process_event
self._fire_event_triggered_transitions(role, _event_type)
File "F:\stable-diffusion-webui\venv\lib\site-packages\h11_state.py", line 311, in _fire_event_triggered_transitions
raise LocalProtocolError(
h11._util.LocalProtocolError: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:12<00:00, 1.61it/s]
Total progress: 40it [00:17, 2.24it/s]
*** API error: POST: http://localhost:7777/api/predict {'error': 'LocalProtocolError', 'detail': '', 'body': '', 'errors': "Can't send data when our state is ERROR"}
Traceback (most recent call last):
File "F:\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\errors.py", line 162, in call
await self.app(scope, receive, _send)
File "F:\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\base.py", line 109, in call
await response(scope, receive, send)
File "F:\stable-diffusion-webui\venv\lib\site-packages\starlette\responses.py", line 270, in call
async with anyio.create_task_group() as task_group:
File "F:\stable-diffusion-webui\venv\lib\site-packages\anyio_backends_asyncio.py", line 597, in aexit
raise exceptions[0]
File "F:\stable-diffusion-webui\venv\lib\site-packages\starlette\responses.py", line 273, in wrap
await func()
File "F:\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\base.py", line 134, in stream_response
return await super().stream_response(send)
File "F:\stable-diffusion-webui\venv\lib\site-packages\starlette\responses.py", line 255, in stream_response
await send(
File "F:\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\errors.py", line 159, in _send
await send(message)
File "F:\stable-diffusion-webui\venv\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 490, in send
output = self.conn.send(event=response)
File "F:\stable-diffusion-webui\venv\lib\site-packages\h11_connection.py", line 512, in send
data_list = self.send_with_data_passthrough(event)
File "F:\stable-diffusion-webui\venv\lib\site-packages\h11_connection.py", line 527, 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
```


### Additional information

_No response_