Title: StreamIDTooLowError when trying to send headers into closed stream · Issue #1175 · python-hyper/h2 · GitHub
Open Graph Title: StreamIDTooLowError when trying to send headers into closed stream · Issue #1175 · python-hyper/h2
X Title: StreamIDTooLowError when trying to send headers into closed stream · Issue #1175 · python-hyper/h2
Description: 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....
Open Graph Description: 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.fu...
X Description: 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 a...
Opengraph URL: https://github.com/python-hyper/h2/issues/1175
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"StreamIDTooLowError when trying to send headers into closed stream","articleBody":"Hi!\r\n\r\nI'm getting errors like this on the server-side:\r\n```pytb\r\nTraceback (most recent call last):\r\n File \"/usr/local/lib/python3.6/dist-packages/grpclib/server.py\", line 310, in request_handler\r\n await method.func(stream)\r\n File \"/usr/local/lib/python3.6/dist-packages/featureflags/server/rpc/service.py\", line 51, in Exchange\r\n await self._queue.StoreStats.add(task, timeout=timeout)\r\n File \"/usr/local/lib/python3.6/dist-packages/taskqueue/client/queue.py\", line 21, in add\r\n await self._task_queue_stub.Add(task, timeout=timeout)\r\n File \"/usr/local/lib/python3.6/dist-packages/grpclib/client.py\", line 473, in __call__\r\n return await stream.recv_message()\r\n File \"/usr/local/lib/python3.6/dist-packages/grpclib/client.py\", line 286, in recv_message\r\n await self.recv_initial_metadata()\r\n File \"/usr/local/lib/python3.6/dist-packages/grpclib/client.py\", line 221, in recv_initial_metadata\r\n headers = await self._stream.recv_headers()\r\n File \"/usr/local/lib/python3.6/dist-packages/grpclib/protocol.py\", line 215, in recv_headers\r\n return await self.__headers__.get()\r\n File \"/usr/lib/python3.6/asyncio/queues.py\", line 167, in get\r\n yield from getter\r\nconcurrent.futures._base.CancelledError\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n File \"/usr/local/lib/python3.6/dist-packages/h2/connection.py\", line 585, in _get_or_create_stream\r\n return self.streams[stream_id]\r\nKeyError: 48141\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n File \"/usr/local/lib/python3.6/dist-packages/grpclib/server.py\", line 325, in request_handler\r\n raise\r\n File \"/usr/local/lib/python3.6/dist-packages/grpclib/server.py\", line 220, in __aexit__\r\n status_message=status_message)\r\n File \"/usr/local/lib/python3.6/dist-packages/grpclib/server.py\", line 170, in send_trailing_metadata\r\n await self._stream.send_headers(headers, end_stream=True)\r\n File \"/usr/local/lib/python3.6/dist-packages/grpclib/protocol.py\", line 267, in send_headers\r\n end_stream=end_stream)\r\n File \"/usr/local/lib/python3.6/dist-packages/h2/connection.py\", line 763, in send_headers\r\n stream_id, AllowedStreamIDs(self.config.client_side)\r\n File \"/usr/local/lib/python3.6/dist-packages/h2/connection.py\", line 587, in _get_or_create_stream\r\n return self._begin_new_stream(stream_id, allowed_ids)\r\n File \"/usr/local/lib/python3.6/dist-packages/h2/connection.py\", line 454, in _begin_new_stream\r\n raise StreamIDTooLowError(stream_id, highest_stream_id)\r\nh2.exceptions.StreamIDTooLowError: StreamIDTooLowError: 48141 is lower than 48143\r\n```\r\nThis happens when client cancels stream with RST_STREAM, and on the server-side I have a logic which looks like this:\r\n```python\r\ntry:\r\n conn.send_headers(stream_id, [...])\r\nexcept h2.exceptions.StreamClosedError:\r\n pass\r\n```\r\nAnd sometimes I'm getting `StreamIDTooLowError` exception instead of `StreamClosedError`, because this behavior depends on `H2Connection.streams` dictionary, where streams are removed nondeterministically.\r\n\r\nI think that `H2Connection._get_or_create_stream` function should check not only `H2Connection.streams` but also `H2Connection._closed_streams`.\r\n\r\nOf 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.","author":{"url":"https://github.com/vmagamedov","@type":"Person","name":"vmagamedov"},"datePublished":"2018-10-25T13:13:42Z","url":"https://github.com/python-hyper/h2/issues/1175"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bbd582f3-96c7-f1a1-88df-0d0df4a77fc4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EB0A:17A21E:36F198D:499F40C:6B06EF9D |
| html-safe-nonce | 90419d727c33b13f6e88338397f37044b448bde2060d05835378535cb7c77f1b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjBBOjE3QTIxRTozNkYxOThEOjQ5OUY0MEM6NkIwNkVGOUQiLCJ2aXNpdG9yX2lkIjoiODU3MDg4MTMwNzEyMTc0MTcyNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b412c216f513007e8152472cb3ff38f03c0af38d609624181335fda490f3eb00 |
| hovercard-subject-tag | issue:373940872 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-hyper/h2/1175/issue_layout |
| twitter:image | https://opengraph.githubassets.com/069dce1c652f45c6adf59d0dd3f1ff69af2258323ce1889b5a2faee8732d797d/python-hyper/h2/issues/1175 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/069dce1c652f45c6adf59d0dd3f1ff69af2258323ce1889b5a2faee8732d797d/python-hyper/h2/issues/1175 |
| og:image:alt | 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.fu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vmagamedov |
| hostname | github.com |
| expected-hostname | github.com |
| None | 351ea5ca38a5758919d44ee52c70fe9003c0c2dfa20f04effd7fac0c5330c16b |
| turbo-cache-control | no-preview |
| go-import | github.com/python-hyper/h2 git https://github.com/python-hyper/h2.git |
| octolytics-dimension-user_id | 13035907 |
| octolytics-dimension-user_login | python-hyper |
| octolytics-dimension-repository_id | 37996233 |
| octolytics-dimension-repository_nwo | python-hyper/h2 |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 37996233 |
| octolytics-dimension-repository_network_root_nwo | python-hyper/h2 |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 891bde3f438884e9c6c7ccd826f33805910a978b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width