Title: http2: closing and then destroying a client stream whose body is still queued sends no RST_STREAM and loops on empty DATA frames until OOM · Issue #67363 · nodejs/node · GitHub
Open Graph Title: http2: closing and then destroying a client stream whose body is still queued sends no RST_STREAM and loops on empty DATA frames until OOM · Issue #67363 · nodejs/node
X Title: http2: closing and then destroying a client stream whose body is still queued sends no RST_STREAM and loops on empty DATA frames until OOM · Issue #67363 · nodejs/node
Description: Version v22.23.4 Platform Linux x64 Subsystem http2 What steps will reproduce the bug? Save as repro.js and run node repro.js (no dependencies). The client runs in a forked child, and the parent kills it at 1 GiB. 'use strict' const http...
Open Graph Description: Version v22.23.4 Platform Linux x64 Subsystem http2 What steps will reproduce the bug? Save as repro.js and run node repro.js (no dependencies). The client runs in a forked child, and the parent ki...
X Description: Version v22.23.4 Platform Linux x64 Subsystem http2 What steps will reproduce the bug? Save as repro.js and run node repro.js (no dependencies). The client runs in a forked child, and the parent ki...
Opengraph URL: https://github.com/nodejs/node/issues/67363
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"http2: closing and then destroying a client stream whose body is still queued sends no RST_STREAM and loops on empty DATA frames until OOM","articleBody":"### Version\n\nv22.23.4 \n\n### Platform\n\n```text\nLinux x64\n```\n\n### Subsystem\n\nhttp2\n\n### What steps will reproduce the bug?\n\nSave as `repro.js` and run `node repro.js` (no dependencies). The client runs in a forked child, and the parent kills it at 1 GiB.\n\n```js\n'use strict'\nconst http2 = require('node:http2')\nconst fs = require('node:fs')\nconst { fork, execFileSync } = require('node:child_process')\n\n// The client runs in a forked child: once the bug triggers, its event loop never runs\n// again, so the parent watches the child's RSS and kills it at 1 GiB.\nif (process.argv[2] === 'child') {\n const session = http2.connect(`http://127.0.0.1:${process.argv[3]}`)\n const req = session.request({ ':method': 'POST', ':path': '/' })\n req.on('error', () => {})\n req.end(Buffer.alloc(2 * 1024 * 1024))\n // Close (NO_ERROR) and destroy while most of the body is still queued behind flow control.\n setTimeout(() => { req.close(); req.destroy() }, 100)\n setInterval(() => {}, 1000)\n return\n}\n\n// Parent: a server that doesn't read the 2 MiB body for 1s, so the upload stalls at the\n// 64 KiB stream window and the abort lands while most of the body is queued.\nfunction rssMiB (pid) {\n try {\n const m = /VmRSS:\\s+(\\d+)/.exec(fs.readFileSync(`/proc/${pid}/status`, 'utf8'))\n if (m) return Number(m[1]) / 1024\n } catch {}\n return Number(execFileSync('ps', ['-o', 'rss=', '-p', String(pid)]).toString().trim()) / 1024\n}\nconst server = http2.createServer()\nserver.on('session', (s) => s.on('error', () => {}))\nserver.on('stream', (stream) => {\n stream.on('error', () => {})\n stream.on('close', () => console.log(`server: stream closed, rstCode=${stream.rstCode}`))\n setTimeout(() => stream.resume(), 1000)\n})\nserver.listen(0, '127.0.0.1', () => {\n const child = fork(__filename, ['child', String(server.address().port)])\n let peak = 0\n const done = (code, msg) => { clearInterval(t); child.kill('SIGKILL'); server.close(); console.log(msg); process.exit(code) }\n const t = setInterval(() => {\n peak = Math.max(peak, rssMiB(child.pid))\n if (peak > 1024) done(1, `RUNAWAY: client RSS passed ${Math.round(peak)} MiB after one aborted upload`)\n }, 100)\n setTimeout(() => done(0, `ok: client RSS peaked at ${Math.round(peak)} MiB`), 5000)\n})\n```\n\n\n### How often does it reproduce? Is there a required condition?\n\nEvery time. The required condition: when the client closes and destroys the stream, part of the request body must still be queued behind flow control, because the server hasn't read it yet. A body that fits in the window, or a server that reads promptly, doesn't trigger it.\n\n### What is the expected behavior? Why is that the expected behavior?\n\n`close()` followed by `destroy()` should leave the stream reset on the wire (RST_STREAM), and the session should go on working with flat memory. Destroying a stream shouldn't leave nghttp2 holding a stream that Node no longer knows about.\n\n### What do you see instead?\n\n```\nRUNAWAY: client RSS passed 1104 MiB after one aborted upload\n```\n\nNo RST_STREAM is sent. Once the server reads the body and sends WINDOW_UPDATE, the client's main thread spins in native code and RSS grows at about 0.5–1 GiB/s until the process is killed. In production OOM reports, the faulting frame is `node::http2::Http2Session::CopyDataIntoOutgoing`.\n\n### Additional information\n\nThe sequence as we understand it:\n\n1. `req.close()` (NO_ERROR) while the writable side is still ending: `closeStream` in `lib/internal/http2/core.js` defers submitting the RST_STREAM until `'finish'`. That never fires, because the body can't flush without window.\n2. `req.destroy()`: `_destroy` doesn't submit an RST because the stream is already closed, and `Http2Stream::Destroy` removes the stream from the session. nghttp2 still has the stream open with its data provider.\n3. On WINDOW_UPDATE, nghttp2 calls `Http2Session::OnRead` (`src/node_http2.cc`). The stream lookup fails and it returns 0 without `NGHTTP2_DATA_FLAG_EOF`. nghttp2 sends a 0-length DATA frame and calls OnRead again. Those frames consume no window, so the `nghttp2_session_mem_send` / `CopyDataIntoOutgoing` loop in `SendPendingData` never ends.\n\nPossible fixes. We haven't built Node to test either one:\n\n- In `_destroy`, submit the RST if `close()` deferred it to `'finish'` and it hasn't gone out yet.\n- As a backstop, have `OnRead` return `NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE` when the stream is gone, so nghttp2 resets it instead of looping.\n\nThe same thing can be reached without calling `close()` directly. undici's HTTP/2 client calls `close()` and then `destroy()` when a request is aborted (UNDICI_ISSUE_LINK). That's how we hit it in production, and nodejs/undici#6181 looks like the same crash.\n\nRelated: #66306 (an `'aborted'` listener destroyed the stream before the RST was submitted). Its fix, #66314, only reorders the `'aborted'` event and doesn't cover this sequence. #66742 (canceled upload leaves session memory over budget) is a separate issue.\n\n_This report was prepared with an AI coding assistant and reviewed by me._","author":{"url":"https://github.com/elyndefigma","@type":"Person","name":"elyndefigma"},"datePublished":"2026-11-09T20:12:05Z","url":"https://github.com/nodejs/node/issues/67363"}
| 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:7928d719-f8a0-fad5-ceab-e497669011b0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B37E:138048:B14214:E5318C:6B063961 |
| html-safe-nonce | b471829f3f4055bab77ea579eeeabc5a8c6b5473d1f76e2907d37e1d9817bb1b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMzdFOjEzODA0ODpCMTQyMTQ6RTUzMThDOjZCMDYzOTYxIiwidmlzaXRvcl9pZCI6IjQwNjM3OTk3MTg2Nzk4MjE3NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c1b8a611f3da8dc388ef8c2fef53ad13804f7eaa007bcb28c02643bd7a1719c6 |
| hovercard-subject-tag | issue:6293851700 |
| 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/67363/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ca3659a599f0ff93677f3e3b9554bfdba8c184dcee5255a8dbc3a94326a69099/nodejs/node/issues/67363 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ca3659a599f0ff93677f3e3b9554bfdba8c184dcee5255a8dbc3a94326a69099/nodejs/node/issues/67363 |
| og:image:alt | Version v22.23.4 Platform Linux x64 Subsystem http2 What steps will reproduce the bug? Save as repro.js and run node repro.js (no dependencies). The client runs in a forked child, and the parent ki... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | elyndefigma |
| hostname | github.com |
| expected-hostname | github.com |
| None | dcf72c457c022486d23c3cbb0dd21aba537a87611ca9ddabd1799cf2eaa9b297 |
| 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 | 0f38f5735226749ec5e08a8649dce4cb2613d9ad |
| 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