StreamIDTooLowError when trying to send headers into closed stream
維護者通常 4 天內回覆
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 48/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- python
- 領域
- networking
研究方向
從 h2/connection.py 中的 H2Connection._get_or_create_stream 和 send_headers 開始,接著檢查 RST_STREAM 之後 streams 和 _closed_streams 的維護方式。重現 closed-stream 路徑並檢查現有的 HTTP/2 測試;完成的標準是,在已重設的 stream 上傳送 headers 時,始終引發預期的 closed-stream 錯誤,而不是 StreamIDTooLowError。
由索引模型根據 Issue 內容生成。
描述
Hi!
I'm getting errors like this on the server-side:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/grpclib/server.py", line 310, in request_handler
await method.func(stream)
File "/usr/local/lib/python3.6/dist-packages/featureflags/server/rpc/service.py", line 51, in Exchange
await self._queue.StoreStats.add(task, timeout=timeout)
File "/usr/local/lib/python3.6/dist-packages/taskqueue/client/queue.py", line 21, in add
await self._task_queue_stub.Add(task, timeout=timeout)
File "/usr/local/lib/python3.6/dist-packages/grpclib/client.py", line 473, in __call__
return await stream.recv_message()
File "/usr/local/lib/python3.6/dist-packages/grpclib/client.py", line 286, in recv_message
await self.recv_initial_metadata()
File "/usr/local/lib/python3.6/dist-packages/grpclib/client.py", line 221, in recv_initial_metadata
headers = await self._stream.recv_headers()
File "/usr/local/lib/python3.6/dist-packages/grpclib/protocol.py", line 215, in recv_headers
return await self.__headers__.get()
File "/usr/lib/python3.6/asyncio/queues.py", line 167, in get
yield from getter
concurrent.futures._base.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/h2/connection.py", line 585, in _get_or_create_stream
return self.streams[stream_id]
KeyError: 48141
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/grpclib/server.py", line 325, in request_handler
raise
File "/usr/local/lib/python3.6/dist-packages/grpclib/server.py", line 220, in __aexit__
status_message=status_message)
File "/usr/local/lib/python3.6/dist-packages/grpclib/server.py", line 170, in send_trailing_metadata
await self._stream.send_headers(headers, end_stream=True)
File "/usr/local/lib/python3.6/dist-packages/grpclib/protocol.py", line 267, in send_headers
end_stream=end_stream)
File "/usr/local/lib/python3.6/dist-packages/h2/connection.py", line 763, in send_headers
stream_id, AllowedStreamIDs(self.config.client_side)
File "/usr/local/lib/python3.6/dist-packages/h2/connection.py", line 587, in _get_or_create_stream
return self._begin_new_stream(stream_id, allowed_ids)
File "/usr/local/lib/python3.6/dist-packages/h2/connection.py", line 454, in _begin_new_stream
raise StreamIDTooLowError(stream_id, highest_stream_id)
h2.exceptions.StreamIDTooLowError: StreamIDTooLowError: 48141 is lower than 48143
This happens when client cancels stream with RST_STREAM, and on the server-side I have a logic which looks like this:
try:
conn.send_headers(stream_id, [...])
except h2.exceptions.StreamClosedError:
pass
And sometimes I'm getting StreamIDTooLowError exception instead of StreamClosedError, because this behavior depends on H2Connection.streams dictionary, where streams are removed nondeterministically.
I think that H2Connection._get_or_create_stream function should check not only H2Connection.streams but also H2Connection._closed_streams.
Of course I can refactor my code and check that stream is closed by myself, but I still think that there is a bug in H2Connection.send_headers method.
- 主要語言
- Python
- 星號
- 1k
- 分支
- 197
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python-hyper/h2 的其他 Issue
-
難度 4/5 3-5 天 新手友好度 45/100
python-hyper/h2#1330 ·
維護者通常 4 天內回覆
-
content-length is not policed when a stream ends with a trailers section可能已有人在做 @feiiiiii5 於 28 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 76/100
python-hyper/h2#1328 ·
維護者通常 4 天內回覆
-
難度 5/5 一週以上 新手友好度 35/100
python-hyper/h2#1312 ·
維護者通常 4 天內回覆
-
難度 4/5 3-5 天 新手友好度 35/100
python-hyper/h2#1280 · 2 則留言 ·
維護者通常 4 天內回覆
-
難度 3/5 1-2 天 新手友好度 45/100
python-hyper/h2#1239 · 3 個 reaction ·
維護者通常 4 天內回覆
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
enhancement good first issue
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 75/100
iceboundrock/AutoForge#304 ·
維護者通常 1 天內回覆
-
enhancement
難度 2/5 1-3 小時 新手友好度 72/100
fossasia/visdom-dev#77 ·
維護者通常 4 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
aws-cloudformation/cfn-lint#4890 ·
維護者通常 2 天內回覆