hypercorn
hypercorn copied to clipboard
Key Error at self.streams[event.stream_id].handle(EndBody(stream_id=event.stream_id)) in _handle_events
trafficstars
The FastAPI app I am building show sometimes the error below. I am not sure if this is the bug of hypercorn or the bug of my code (The code is working fine when I was using uvicorn).
Is there any idea to fix this?
+ Exception Group Traceback (most recent call last):
| File "/usr/local/lib/python3.11/site-packages/hypercorn/asyncio/run.py", line 96, in _server_callback
| await TCPServer(app, loop, config, context, reader, writer)
| File "/usr/local/lib/python3.11/site-packages/hypercorn/asyncio/tcp_server.py", line 56, in run
| async with TaskGroup(self.loop) as task_group:
| File "/usr/local/lib/python3.11/site-packages/hypercorn/asyncio/task_group.py", line 74, in __aexit__
| await self._task_group.__aexit__(exc_type, exc_value, tb)
| File "/usr/local/lib/python3.11/asyncio/taskgroups.py", line 147, in __aexit__
| raise me from None
| ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
+-+---------------- 1 ----------------
| Traceback (most recent call last):
| File "/usr/local/lib/python3.11/site-packages/hypercorn/asyncio/tcp_server.py", line 70, in run
| await self._read_data()
| File "/usr/local/lib/python3.11/site-packages/hypercorn/asyncio/tcp_server.py", line 105, in _read_data
| await self.protocol.handle(RawData(data))
| File "/usr/local/lib/python3.11/site-packages/hypercorn/protocol/__init__.py", line 62, in handle
| return await self.protocol.handle(event)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/usr/local/lib/python3.11/site-packages/hypercorn/protocol/h2.py", line 188, in handle
| await self._handle_events(events)
| File "/usr/local/lib/python3.11/site-packages/hypercorn/protocol/h2.py", line 255, in _handle_events
| await self.streams[event.stream_id].handle(EndBody(stream_id=event.stream_id))
| ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
| KeyError: 3
+------------------------------------
Hello! I'm getting the same error here when uploading file trough FastAPI. Any ideas?
Fixed in 24aacf432ef44ddf8ba32e2427b507e560f63ce2