Title: http2: server sends RST_STREAM(NO_ERROR) without END_STREAM when the connection window is exhausted, truncating complete responses · Issue #66525 · nodejs/node · GitHub
Open Graph Title: http2: server sends RST_STREAM(NO_ERROR) without END_STREAM when the connection window is exhausted, truncating complete responses · Issue #66525 · nodejs/node
X Title: http2: server sends RST_STREAM(NO_ERROR) without END_STREAM when the connection window is exhausted, truncating complete responses · Issue #66525 · nodejs/node
Description: Version v26.10.0 (nghttp2 1.70.0); also reproduced on v26.5.1 and v24.18.0 (nghttp2 1.69.0). The code path is unchanged on main. Platform Darwin 25.6.0 arm64 Subsystem http2 What steps will reproduce the bug? Disclaimer: The following re...
Open Graph Description: Version v26.10.0 (nghttp2 1.70.0); also reproduced on v26.5.1 and v24.18.0 (nghttp2 1.69.0). The code path is unchanged on main. Platform Darwin 25.6.0 arm64 Subsystem http2 What steps will reprodu...
X Description: Version v26.10.0 (nghttp2 1.70.0); also reproduced on v26.5.1 and v24.18.0 (nghttp2 1.69.0). The code path is unchanged on main. Platform Darwin 25.6.0 arm64 Subsystem http2 What steps will reprodu...
Opengraph URL: https://github.com/nodejs/node/issues/66525
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"http2: server sends RST_STREAM(NO_ERROR) without END_STREAM when the connection window is exhausted, truncating complete responses","articleBody":"### Version\n\nv26.10.0 (nghttp2 1.70.0); also reproduced on v26.5.1 and v24.18.0 (nghttp2 1.69.0). The code path is unchanged on `main`.\n\n### Platform\n\n```text\nDarwin 25.6.0 arm64\n```\n\n### Subsystem\n\nhttp2\n\n### What steps will reproduce the bug?\n\nDisclaimer: The following research and reproduction were done together with Claude Opus 5.5\n\nSave as `repro.mjs` and run `node repro.mjs`. There are no dependencies and no TLS. A raw h2c client never sends WINDOW_UPDATE, so the 65535-byte connection window stays exhausted until the client reopens it after 300 ms.\n\n```js\nimport http2 from 'node:http2';\nimport net from 'node:net';\n\nconst server = http2.createServer();\nconst pending = {};\nserver.on('request', (req, res) => {\n pending[req.url] = res;\n if (!pending['/small'] || !pending['/big']) return;\n // Once /small's body is on the wire, /big drains the 65535-byte connection window\n // before /small's END_STREAM frame is submitted.\n pending['/small'].stream.once('wantTrailers', () => pending['/big'].end('y'.repeat(1_000_000)));\n pending['/small'].end('x'.repeat(1000));\n});\nif (process.env.RESUME) server.on('stream', (s) => s.resume());\n\n// Raw h2c client that never sends WINDOW_UPDATE, so the connection window stays at 0 once drained.\nconst frame = (type, flags, id, payload = Buffer.alloc(0)) => {\n const h = Buffer.alloc(9);\n h.writeUIntBE(payload.length, 0, 3);\n h[3] = type; h[4] = flags; h.writeUInt32BE(id, 5);\n return Buffer.concat([h, payload]);\n};\nconst lit = (idx, v) => Buffer.concat([Buffer.from([idx, v.length]), Buffer.from(v)]); // literal, indexed name, no huffman\nconst headers = (path) => Buffer.concat([Buffer.from([0x82, 0x86]), lit(0x04, path), lit(0x01, 'localhost')]); // GET, http\nconst TYPES = { 0: 'DATA', 1: 'HEADERS', 3: 'RST_STREAM', 4: 'SETTINGS', 6: 'PING', 7: 'GOAWAY', 8: 'WINDOW_UPDATE' };\n\nserver.listen(0, () => {\n const sock = net.connect(server.address().port, 'localhost', () => {\n sock.write(Buffer.concat([\n Buffer.from('PRI * HTTP/2.0\\r\\n\\r\\nSM\\r\\n\\r\\n'),\n frame(4, 0, 0),\n frame(1, 0x5, 1, headers('/big')), // END_STREAM | END_HEADERS\n frame(1, 0x5, 3, headers('/small')),\n ]));\n });\n let buf = Buffer.alloc(0), small = [], done = false;\n const finish = (verdict) => {\n if (done) return;\n done = true;\n console.log(`node ${process.version} resume=${!!process.env.RESUME}: /small frames: ${small.join(', ')}\\n=> ${verdict}`);\n process.exitCode = verdict.startsWith('OK') ? 0 : 1;\n sock.destroy(); server.close();\n };\n sock.on('data', (d) => {\n buf = Buffer.concat([buf, d]);\n while (buf.length >= 9 && buf.length >= 9 + buf.readUIntBE(0, 3)) {\n const len = buf.readUIntBE(0, 3), type = buf[3], flags = buf[4], id = buf.readUInt32BE(5) & 0x7fffffff;\n const payload = buf.subarray(9, 9 + len);\n buf = buf.subarray(9 + len);\n if (type === 4 && !(flags & 1)) sock.write(frame(4, 1, 0)); // SETTINGS ack\n if (id !== 3) continue;\n const endStream = (type === 0 || type === 1) && flags & 1;\n small.push(`${TYPES[type]}(${type === 0 ? `${len}B` : type === 3 ? `code=${payload.readUInt32BE(0)}` : 'headers'}${endStream ? ', END_STREAM' : ''})`);\n if (endStream) finish('OK: response completed with END_STREAM');\n if (type === 3) finish('BUG: full body received, then RST_STREAM without END_STREAM');\n }\n });\n // Reopen the connection window later; a correct server sends /small's END_STREAM then.\n const win = Buffer.alloc(4); win.writeUInt32BE(10_000_000);\n setTimeout(() => sock.write(Buffer.concat([frame(8, 0, 0, win), frame(8, 0, 1, win)])), 300);\n setTimeout(() => finish('TIMEOUT: /small never finished'), 2000);\n});\n```\n\nThe `wantTrailers` listener only makes the timing deterministic. In real traffic the same state comes about by itself whenever large responses use up the connection window while smaller responses on the same session finish.\n\n\n### How often does it reproduce? Is there a required condition?\n\nEvery time with the script above (5/5 on each version listed).\n\nRequired condition: a compat-API response (`Http2ServerResponse`, which always responds with `waitForTrailers: true`) whose request had no body. Its body has been sent, but the connection flow-control window is 0 when its empty END_STREAM DATA frame is submitted.\n\n\n### What is the expected behavior? Why is that the expected behavior?\n\n```text\nnode v26.10.0 resume=false: /small frames: HEADERS(headers), DATA(1000B), DATA(0B, END_STREAM)\n=> OK: response completed with END_STREAM\n```\n\nThe END_STREAM frame should wait for the window to open, then be sent. It does with `RESUME=1` (see below).\n\nRFC 9113 §8.1 only allows a server to send `RST_STREAM` with `NO_ERROR` *after* a complete response, \"i.e., a frame with the END_STREAM flag set\". Its purpose is to stop a request body the server doesn't need. Here the request already ended with its HEADERS frame, so there is nothing to abort.\n\n\n### What do you see instead?\n\n```text\nnode v26.10.0 resume=false: /small frames: HEADERS(headers), DATA(1000B), RST_STREAM(code=0)\n=> BUG: full body received, then RST_STREAM without END_STREAM\n```\n\nThe client gets the whole body, but the stream ends with a reset instead of END_STREAM, so it can't tell the response is complete. Firefox reports these as `NS_ERROR_NET_PARTIAL_TRANSFER` and discards the response. With `RESUME=1` the same script passes:\n\n```text\nnode v26.10.0 resume=true: /small frames: HEADERS(headers), DATA(1000B), DATA(0B, END_STREAM)\n=> OK: response completed with END_STREAM\n```\n\n\n### Additional information\n\n**Mechanism** (`lib/internal/http2/core.js`, `src/node_http2.cc`):\n\n1. The compat API responds with `waitForTrailers: true`. The body's last DATA frame goes out without END_STREAM, and `wantTrailers` → `sendTrailers({})` → `setImmediate(finishSendTrailers)` submits an empty DATA frame with END_STREAM (`Http2Stream::SubmitTrailers`).\n2. `finishSendTrailers` calls `stream[kMaybeDestroy]()`. The stream is `writableFinished`, has no trailers flag any more, `!didRead`, and `readableFlowing === null`. So it takes the \"gracefully close\" branch and calls `setImmediate(callStreamClose)` → `stream.close()` → `closeStream()` → `RST_STREAM(NO_ERROR)` straight away, because `writableFinished` is true.\n3. If the connection window is 0 at that moment, nghttp2 defers the empty END_STREAM DATA frame by flow control, even though it carries 0 bytes. RST_STREAM isn't flow-controlled, so it goes out first, and the deferred END_STREAM frame is dropped with the stream.\n\n**Native trace from a real server** (`NODE_DEBUG_NATIVE=HTTP2SESSION,HTTP2STREAM`, Vite dev server, Firefox). This is stream 207 of a session that was also sending 5 MB, 3 MB and 2.7 MB responses:\n\n```text\nHttpStream 207 ... submitting response\nHttp2Session server ... sending 3478 bytes for data frame on stream 207\nHttpStream 207 ... writable side shutdown\nHttp2Session server ... no more data for stream 207\nHttpStream 207 ... let javascript know we are ready for trailers\nHttpStream 207 ... sending 0 trailers\n (~2300 log lines: ~50 more streams submit trailers, one WINDOW_UPDATE arrives, all of it goes to the multi-MB streams)\nHttp2Session server ... write finished with status 0\nHttpStream 207 ... sending rst_stream with code 0\nHttp2Session server ... stream 207 closed with code: 0\n```\n\nIn that capture, 88 of 335 streams had this sequence: \"no more data\" logged once instead of twice, END_STREAM never sent. All 88 matched the 88 `NS_ERROR_NET_PARTIAL_TRANSFER` failures Firefox reported across 3 page loads.\n\n**Workaround:** mark bodyless request streams as read, so the graceful-close branch is skipped and the stream closes normally after END_STREAM:\n\n```js\nserver.on('stream', (stream) => { if (stream.endAfterHeaders) stream.resume(); });\n```\n\n**Possible fixes** (not tested): skip the graceful close when the request side has already ended (`endAfterHeaders` / readable ended), since there is no request body to abort. Or defer the RST until the END_STREAM frame has actually been sent.\n\n**Impact:** Vite's dev server uses `http2.createSecureServer` with the compat API. Since Vite 7.2 it also does so when a proxy is configured, so Angular CLI dev servers are affected too. Large apps randomly fail to load modules in Firefox: vitejs/vite#21569, vitejs/vite#18182, vitejs/vite discussion #21574.\n","author":{"url":"https://github.com/iNaD","@type":"Person","name":"iNaD"},"datePublished":"2026-10-05T07:32:06Z","url":"https://github.com/nodejs/node/issues/66525"}
| 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:2f22eca0-7118-4b66-3b07-1259912d140f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 93BE:3DE7C3:107B07:14DCD7:6B033860 |
| html-safe-nonce | 0d90ca8342fc8eb8767e9ada5f1a6fffaf5a1c2b91906e4b70e90177a102fbe8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5M0JFOjNERTdDMzoxMDdCMDc6MTREQ0Q3OjZCMDMzODYwIiwidmlzaXRvcl9pZCI6IjQyMjk3OTQ0OTIzNjE3NDk0NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5645d3fc08929db8fbe129e89325f3ef5bfab032967bf6960b769f169032cb59 |
| hovercard-subject-tag | issue:5708168194 |
| 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/66525/issue_layout |
| twitter:image | https://opengraph.githubassets.com/20c9cab2f052874a35488c403ab4a241a820bcd245a3bc783f51d402331a2b2b/nodejs/node/issues/66525 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/20c9cab2f052874a35488c403ab4a241a820bcd245a3bc783f51d402331a2b2b/nodejs/node/issues/66525 |
| og:image:alt | Version v26.10.0 (nghttp2 1.70.0); also reproduced on v26.5.1 and v24.18.0 (nghttp2 1.69.0). The code path is unchanged on main. Platform Darwin 25.6.0 arm64 Subsystem http2 What steps will reprodu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | iNaD |
| 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