Title: http2: async iterator rejects complete buffered response after NO_ERROR reset with request side open · Issue #66693 · nodejs/node · GitHub
Open Graph Title: http2: async iterator rejects complete buffered response after NO_ERROR reset with request side open · Issue #66693 · nodejs/node
X Title: http2: async iterator rejects complete buffered response after NO_ERROR reset with request side open · Issue #66693 · nodejs/node
Description: Version Reproduced on v24.18.0 and v26.11.1, with 20/20 failures on each. v26.11.1 was the node npm package's latest version when tested. Platform Linux 6.12.95+deb13-amd64, x86_64 GNU/Linux. The installed v24.18.0 reports nghttp2 1.69.0...
Open Graph Description: Version Reproduced on v24.18.0 and v26.11.1, with 20/20 failures on each. v26.11.1 was the node npm package's latest version when tested. Platform Linux 6.12.95+deb13-amd64, x86_64 GNU/Linux. The i...
X Description: Version Reproduced on v24.18.0 and v26.11.1, with 20/20 failures on each. v26.11.1 was the node npm package's latest version when tested. Platform Linux 6.12.95+deb13-amd64, x86_64 GNU/Linux. T...
Opengraph URL: https://github.com/nodejs/node/issues/66693
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"http2: async iterator rejects complete buffered response after NO_ERROR reset with request side open","articleBody":"### Version\n\nReproduced on **v24.18.0** and **v26.11.1**, with 20/20 failures on each. v26.11.1 was the `node` npm package's latest version when tested.\n\n### Platform\n\nLinux 6.12.95+deb13-amd64, x86_64 GNU/Linux.\n\nThe installed v24.18.0 reports nghttp2 1.69.0 and OpenSSL 3.5.7. v26.11.1 was tested using `npm exec --yes --package=node@26.11.1 -- node ...`.\n\n### Subsystem\n\n`http2`, `stream` (`ClientHttp2Stream` readable async iteration / end-of-stream handling).\n\n### What steps will reproduce the bug?\n\nA standalone, dependency-free reproduction gist:\n\nhttps://gist.github.com/jbeda/cb47933e03eb33febf937c159b780b9b\n\nPinned script: https://gist.githubusercontent.com/jbeda/cb47933e03eb33febf937c159b780b9b/raw/6502872f0d06b6c3b93ee1c83ab17b4c19dbe7e2/repro.mjs\n\nSave the gist's `repro.mjs` locally and run:\n\n```sh\nnode repro.mjs\n```\n\nNo package installation, proxy, Go server, or gRPC library is required. It uses `node:http2` as the client and a small `node:net` peer bound to a loopback ephemeral port. The peer writes explicit HTTP/2 frames with a static-table `:status: 200` HPACK entry and a literal `grpc-status: 0` trailer. The body is synthetic plain bytes, not protobuf or gRPC framing.\n\nThe script synchronizes on events, without scheduling sleeps or retries:\n\n1. Client starts a POST, writes some request bytes, and deliberately does **not** call `request.end()`.\n2. Peer sends response HEADERS and initial DATA.\n3. Client creates the built-in async iterator, consumes the initial DATA, verifies `writableEnded === false`, then pauses iteration.\n4. Peer sends final DATA, trailers with `END_STREAM`, and `RST_STREAM(NO_ERROR)` in that order in one socket write. The reset does not overtake the response bytes on the wire.\n5. Client waits for trailers and the reset-induced `aborted` event. It verifies `grpc-status === '0'`, `rstCode === 0`, and that all 17 final response bytes remain buffered.\n6. Client resumes the **existing** iterator. It receives and verifies the exact final bytes.\n7. The following `next()` throws `ERR_STREAM_PREMATURE_CLOSE` instead of returning EOF.\n\nThe five-second timeout only catches a hung reproduction. Session/socket destruction is in `finally`, after the EOF read; it does not cause the failure.\n\n### How often does it reproduce? Is there a required condition?\n\nDeterministic with the event-gated sequence above. I tested the failing case and both controls 20 times each on both runtimes, checking the failing exit status, specific error code, and complete-byte receipt:\n\n| Version | Buffered final DATA + NO_ERROR reset | Same exchange without reset | Final DATA consumed before trailers/reset |\n| --- | --- | --- | --- |\n| v24.18.0 | 20/20 `ERR_STREAM_PREMATURE_CLOSE` | 20/20 clean EOF | 20/20 clean EOF |\n| v26.11.1 | 20/20 `ERR_STREAM_PREMATURE_CLOSE` | 20/20 clean EOF | 20/20 clean EOF |\n\nControls:\n\n```sh\nnode repro.mjs no-reset\nnode repro.mjs drained\n```\n\nThe relevant conditions are an open request side, an already-created readable async iterator, and response DATA still buffered when a post-response `NO_ERROR` reset arrives. Without event gating, this manifests intermittently in application traffic.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nThe request side is closed by the reset, but the complete response remains consumable and the readable iterator finishes normally. Successful response END_STREAM has already arrived and every response byte can still be read.\n\nRFC 9113 section 8.1 explicitly permits `RST_STREAM(NO_ERROR)` after a complete response while a request remains in progress and says clients must not discard responses because of such a reset. Both control cases demonstrate clean EOF on the same response content.\n\n### What do you see instead?\n\nOn v24.18.0:\n\n```text\n{\"node\":\"v24.18.0\",\"mode\":\"reset\",\"status\":\"0\",\"rstCode\":0,\"readableLength\":17,\"writableEnded\":true}\nComplete response bytes received.\nnode:internal/streams/end-of-stream:166\n new ERR_STREAM_PREMATURE_CLOSE());\n ^\n\nError [ERR_STREAM_PREMATURE_CLOSE]: Premature close\n at ClientHttp2Stream.onclose (node:internal/streams/end-of-stream:166:30)\n at ClientHttp2Stream.emit (node:events:521:24)\n at closeStream (node:internal/http2/core:2033:14)\n at Http2Stream.onStreamClose (node:internal/http2/core:605:5) {\n code: 'ERR_STREAM_PREMATURE_CLOSE'\n}\n\nNode.js v24.18.0\n```\n\n`writableEnded` becomes true upon reset; it was explicitly checked as false before sending completion, and the script never calls `request.end()`.\n\nv26.11.1 also yields all response bytes and then throws, with `getEosOnCloseError` at `end-of-stream:98`, `onclose` at `end-of-stream:265`, and `closeStream` at `http2/core:2088`.\n\n### Additional information\n\n**Related, but a different reproducer from #65677 / #65689:** that issue ends the request and begins iteration after normal stream closure. It lists v24.18.0 as passing. This case leaves the request open and starts/consumes the iterator before closure; it fails on v24.18.0 as well. I have not tested #65689's proposed patch against this case and am not claiming it fixes or fails to fix it.\n\nThe observed sequence suggests readable end-of-stream handling interprets the reset-induced duplex `aborted` event as premature response termination while completed-response bytes are buffered. Those bytes can subsequently be yielded, but the iterator retains a premature-close error for its next read. This is a mechanism hypothesis for maintainers to validate, not a proposed production monkeypatch.\n\nThis was observed in the wild with gRPC, but it is a more general HTTP/2 response-consumption issue. The standalone reproduction uses only Node core and synthetic response bytes; it does not depend on gRPC or an application framework.\n\nFiling this to determine whether the open-request/active-iterator case belongs with #65677 or requires separate handling.\n","author":{"url":"https://github.com/jbeda","@type":"Person","name":"jbeda"},"datePublished":"2026-10-13T02:15:19Z","url":"https://github.com/nodejs/node/issues/66693"}
| 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:4657c682-12b7-0cfb-f893-c8f4d1970f4e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 89D6:220853:B4285:EEDEE:6B036A24 |
| html-safe-nonce | ace13711b88a307bc598d4623f6047f4b7e594e841a089191fc7a2af3dc58cf6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OUQ2OjIyMDg1MzpCNDI4NTpFRURFRTo2QjAzNkEyNCIsInZpc2l0b3JfaWQiOiI0NDEyNzUwOTM0NzMyNjYzMzMzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b9521a17e6fdd0cee4dd9b2ba2dc08fec08ad997c11d40a5cb7f00d2f3a0a95b |
| hovercard-subject-tag | issue:5823352411 |
| 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/nodejs/node/66693/issue_layout |
| twitter:image | https://opengraph.githubassets.com/616691dc339e864b2f53a2b543ba7c84aa8eb6ee2dd4c8039d985a8ea5625b38/nodejs/node/issues/66693 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/616691dc339e864b2f53a2b543ba7c84aa8eb6ee2dd4c8039d985a8ea5625b38/nodejs/node/issues/66693 |
| og:image:alt | Version Reproduced on v24.18.0 and v26.11.1, with 20/20 failures on each. v26.11.1 was the node npm package's latest version when tested. Platform Linux 6.12.95+deb13-amd64, x86_64 GNU/Linux. The i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jbeda |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| 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