GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — http2: release queued data memory on stream cancellation by inoway46 · Pull Request #67113 · nodejs/node

Conversation

@inoway46

@inoway46 inoway46 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Canceling a stream with queued outbound data leaves that data charged to maxSessionMemory. Subsequent requests on the same session can then fail even though the queued data has been discarded.

Release the remaining outbound memory accounting when cleaning up the stream's write queue, and add a regression test for session reuse after cancellation.

Found while investigating #66739. This does not change response-header admission or resolve the early-response issue itself.

Refs: #66739

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nodejs-github-bot

nodejs-github-bot commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http2
  • @nodejs/net
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. http2 Issues and PRs related to the http2 subsystem. needs-ci PRs that need a full CI run. labels Oct 29, 2026
@inoway46
http2: release queued data memory on stream cancellation
15bcc85
Release the memory charged for queued outbound data when a stream is
canceled, so subsequent requests can reuse the session's memory budget.

Refs: nodejs#66739
Assisted-by: Codex
Signed-off-by: inoway46 <[email protected]>
@inoway46
inoway46 force-pushed the fix-http2-cancel-memory-accounting branch from f8ee532 to 15bcc85 Compare October 29, 2026 16:27
@inoway46
inoway46 marked this pull request as ready for review October 29, 2026 16:29
@inoway46
inoway46 requested a review from pimterry October 29, 2026 16:30
@inoway46 inoway46 mentioned this pull request Oct 29, 2026
http2: exclude queued data from response memory checks #67114
Merged
mcollina
mcollina approved these changes Oct 29, 2026
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

inoway46 reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 29, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 29, 2026
@nodejs-github-bot

nodejs-github-bot commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78712/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codecov

codecov Bot commented Oct 29, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.66%. Comparing base (98dbf60) to head (15bcc85).
⚠️ Report is 51 commits behind head on main.

Files with missing lines Patch % Lines
src/node_http2.cc 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #67113    +/-   ##
========================================
  Coverage   90.65%   90.66%            
========================================
  Files         797      797            
  Lines      278268   278793   +525     
  Branches    53517    53617   +100     
========================================
+ Hits       252261   252763   +502     
+ Misses      16386    16381     -5     
- Partials     9621     9649    +28     
Files with missing lines Coverage Δ
src/node_http2.cc 82.05% <50.00%> (-0.08%) ⬇️

... and 42 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@inoway46 inoway46 added the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Oct 30, 2026
@github-actions github-actions Bot removed the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Oct 30, 2026
@nodejs-github-bot

nodejs-github-bot commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78720/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@inoway46 inoway46 added author ready PRs with CI started, the required approvals, and no outstanding review comments. and removed needs-ci PRs that need a full CI run. labels Oct 30, 2026
pimterry
pimterry approved these changes Oct 30, 2026
View reviewed changes
@pimterry pimterry added the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 30, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 80a74e1 into nodejs:main Oct 31, 2026
94 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

Landed in 80a74e1

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 31, 2026
inoway46 added a commit to inoway46/node that referenced this pull request Nov 1, 2026
@inoway46
http2: exclude queued data from response memory checks
151b1b8
Allow clients to receive responses when queued request data exceeds
maxSessionMemory, while preserving limits on received headers.

Fixes: nodejs#66739
Refs: nodejs#67113
Assisted-by: Codex
Signed-off-by: inoway46 <[email protected]>
This was referenced Nov 1, 2026
http2: canceled upload leaves session memory accounting over budget #66742
Closed
http2: release memory credit for canceled writes #66784
Merged
fatihguzeldev added a commit to fatihguzeldev/node that referenced this pull request Nov 1, 2026
@fatihguzeldev
http2: drop memory fix merged in nodejs#67113
9ded7bd
Signed-off-by: Fatih Güzel <[email protected]>
@devin-ai-integration devin-ai-integration Bot mentioned this pull request Nov 3, 2026
fix(js-sdk): keep envd HTTP/2 sessions within Node's session memory budget e2b-dev/E2B#2083
Closed
@mishushakov

mishushakov commented Nov 3, 2026

Copy link
Copy Markdown

Could this get backport-requested-v24.x / backport-requested-v22.x (and land in v25.x)? We are hitting the leak this fixes in production through undici's HTTP/2 client.

Impact. undici ≥ 8 multiplexes up to 100 streams on one long-lived Http2Session. Every stream that is destroyed before its queued body is flushed (request timeout, AbortSignal, peer RST_STREAM, GOAWAY mid-upload) permanently loses its queued bytes from the session's maxSessionMemory budget. Once the budget is gone, Http2Stream::AddHeader fails for every later response on that session and Node resets each of them locally with NGHTTP2_ENHANCE_YOUR_CALM (surfaced by fetch as TypeError: fetch failed, cause ERR_HTTP2_STREAM_ERROR). A busy process never lets the session go idle, so it never recovers.

Measured on v24.22.2 (undici 8.12.3, maxSessionMemory: 1 to shorten the repro):

before abort : 50/50 small POSTs ok
one 16 MiB POST aborted after 300 ms
after abort  : 0/50 ok — every request RST(ENHANCE_YOUR_CALM), still 0/50 two seconds later

With the default 10 MB budget a single aborted 16 MiB upload loses 2–5 MB of it for the session's lifetime (checked by bisecting maxSessionMemory: 2 → poisoned, 5 → not).

Minimal repro (no undici, plain http2):

const http2 = require('node:http2')
const session = http2.connect('https://<any-h2-origin-accepting-uploads>', { maxSessionMemory: 1 })

function post (body, ms) {
  return new Promise((resolve) => {
    const req = session.request({ ':method': 'POST', ':path': '/upload' })
    req.on('response', (h) => resolve({ status: h[':status'] }))
    req.on('close', () => resolve({ rstCode: req.rstCode }))
    req.end(body)
    if (ms) setTimeout(() => req.destroy(), ms) // abort while body is still queued
  })
}

;(async () => {
  console.log(await post(Buffer.alloc(16 << 20), 300))      // { rstCode: 8 } CANCEL, expected
  console.log(await post(Buffer.alloc(4096)))                // { rstCode: 11 } ENHANCE_YOUR_CALM — leaked budget
  console.log(await post(Buffer.alloc(4096)))                // { rstCode: 11 } forever
})()

Context: e2b-dev/e2b SDK-425 — concurrent files.write() failing with ENHANCE_YOUR_CALM after moving from undici 7 (one stream per session) to undici 8 (100 streams per session).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mishushakov mishushakov mentioned this pull request Nov 3, 2026
H2: a session Node has reset for memory (ENHANCE_YOUR_CALM) stays in the pool and fails every later request nodejs/undici#6149
Open
@inoway46

inoway46 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed report! Given the production impact, I agree this is worth backporting to the supported LTS lines.

mishushakov reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@inoway46 inoway46 added lts-watch-v22.x PRs that may need to be released in v22.x lts-watch-v24.x PRs that may need to be released in v24.x lts-watch-v26.x PRs that may need to be released in v26.x. labels Nov 3, 2026
@devin-ai-integration devin-ai-integration Bot mentioned this pull request Nov 3, 2026
fix(js-sdk): send envd file uploads over HTTP/1.1, retire poisoned HTTP/2 dispatchers e2b-dev/E2B#2086
Merged
mishushakov added a commit to e2b-dev/E2B that referenced this pull request Nov 3, 2026
@devin-ai-integration @mishushakov
fix(js-sdk): send envd file uploads over HTTP/1.1, retire poisoned HT…
08f05bb
…TP/2 dispatchers (#2086)

## Summary

Fixes [SDK-425](https://linear.app/e2b/issue/SDK-425): concurrent
`sandbox.files.write()` calls fail with `TypeError: fetch failed` →
`NGHTTP2_ENHANCE_YOUR_CALM` since `e2b` ≥ 2.35 (undici 8). Simpler
alternative to #2083 (byte budget + one-off sessions), same
measurements.

**Cause.** The RST is sent by Node's own http2 client, not by E2B infra.
Node queues each buffered request body in full against the session's 10
MB `maxSessionMemory`; if a response HEADERS frame arrives on *any*
stream while that budget is exhausted, Node resets that stream with
`ENHANCE_YOUR_CALM`. undici 7 kept one request per session (so our
10-connection pool = 10 budgets); undici 8 multiplexes, so every envd
REST request in the process shares one session and one budget — parallel
or large uploads reset each other and the reads next to them. Streams
destroyed before their body is flushed (timeouts, aborts, killed
sandboxes) additionally leak their queued bytes on Node ≤ 24 (fixed on
`main` by nodejs/node#67113), so a session degrades until every small
write on it fails — the customer's "climbing since Monday".

**Fix (JS SDK only — Python uses pyqwest/hyper, not Node http2):**

1. `Filesystem` POSTs `/files` (octet-stream, streamed, gzip and
multipart uploads) through `createEnvdUploadFetch` — an HTTP/1.1
dispatcher pool of its own (`E2B_ENVD_UPLOAD_CONNECTIONS`, default 50,
like `E2B_ENVD_RPC_CONNECTIONS`); everything else (`read`, `makeDir`,
RPC, health…) stays on HTTP/2, and `httpVersion` / `E2B_HTTP_VERSION`
keep governing those. The `ConnectionOpts.httpVersion` JSDoc documents
the exception.
   ```ts
   // sandbox/filesystem/index.ts
const uploadFetch = createEnvdUploadFetch({ proxy:
connectionConfig.proxy })
   …
   this.envdApi.api.POST('/files', { …, fetch: this.uploadFetch })
   ```
One request per connection, no shared memory budget — what undici 7
effectively gave 2.27.1 (which capped uploads at 10 per process; this
pool allows 50, beyond that uploads queue in undici with their request
timeout running).
2. `buildDispatchedFetch` (`src/undici.ts`): a request that fails with
`ERR_HTTP2_STREAM_ERROR` +
`NGHTTP2_ENHANCE_YOUR_CALM`/`NGHTTP2_INTERNAL_ERROR`
(`isPoisonedHTTP2SessionError`) retires that dispatcher and builds a
fresh one for subsequent requests. The failed request is **not**
replayed (envd may already have applied the write). Only the dispatcher
that served the failing request can replace the current one. Safety net
for whatever else might fill a session.

No API change.

**Measured** (built package, real sandboxes, Node 24.22; ALPN confirmed:
writes `http/1.1`, reads `h2`):

| scenario | 2.62.1 | this PR |
|---|---|---|
| 10 × 2 MB parallel writes, 5 rounds | 16/50 failed | 0/50 |
| 30 × 1 MB, 20 × 1 MB, 4 × 16 MB, customer pattern (makeDir + 10
parallel small writes ×200) | — | 0 failed |
| 16 MB write + 10 concurrent `files.read()` | 30/30 reads failed | 0/33
|
| poisoned session (`maxSessionMemory=1`, aborted big writes) | 50/50
fail, forever | 0 failed |
| streamed (async iterable), gzip, multipart, string, aborted upload | —
| all OK |

**Upstream:** backport request on nodejs/node#67113
(nodejs/node#67113 (comment)) and
undici issue nodejs/undici#6149.

Link to Devin session:
https://app.devin.ai/sessions/98f09d080013403b954d3f7b07c51b3b
Open in Devin Desktop:
https://app.devin.ai/desktop/session/98f09d080013403b954d3f7b07c51b3b?variant=devin
Requested by: @mishushakov

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: [email protected] <[email protected]>
nodejs-github-bot pushed a commit that referenced this pull request Nov 4, 2026
@inoway46
http2: exclude queued data from response memory checks
20daf9a
Allow clients to receive responses when queued request data exceeds
maxSessionMemory, while preserving limits on received headers.

Fixes: #66739
Refs: #67113
Assisted-by: Codex
Signed-off-by: inoway46 <[email protected]>
PR-URL: #67114
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Tim Perry <[email protected]>
@gabedemesa gabedemesa mentioned this pull request Nov 9, 2026
HTTP/2: client session outgoing queue grows without bound (Http2Session::CopyDataIntoOutgoing), OOM-killing the process nodejs/undici#6181
Open
@ghost ghost mentioned this pull request Nov 9, 2026
feat(container)!: Update image docker.io/library/node (24.22.2 ➔ 26.13.0) - autoclosed janpuc/home-ops#1777
Closed
1 task
aduh95 pushed a commit that referenced this pull request Nov 11, 2026
@inoway46 @aduh95
http2: release queued data memory on stream cancellation
ed688a4
Release the memory charged for queued outbound data when a stream is
canceled, so subsequent requests can reuse the session's memory budget.

Refs: #66739
Assisted-by: Codex
Signed-off-by: inoway46 <[email protected]>
PR-URL: #67113
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Tim Perry <[email protected]>
aduh95 pushed a commit that referenced this pull request Nov 11, 2026
@inoway46 @aduh95
http2: exclude queued data from response memory checks
8d45d5b
Allow clients to receive responses when queued request data exceeds
maxSessionMemory, while preserving limits on received headers.

Fixes: #66739
Refs: #67113
Assisted-by: Codex
Signed-off-by: inoway46 <[email protected]>
PR-URL: #67114
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Tim Perry <[email protected]>
@github-actions github-actions Bot mentioned this pull request Nov 11, 2026
2026-11-12, Version 27.0.0-alpha.0.1.0 (Alpha) #67415
Merged
aduh95 pushed a commit that referenced this pull request Nov 12, 2026
@inoway46 @aduh95
http2: release queued data memory on stream cancellation
19957e3
Release the memory charged for queued outbound data when a stream is
canceled, so subsequent requests can reuse the session's memory budget.

Refs: #66739
Assisted-by: Codex
Signed-off-by: inoway46 <[email protected]>
PR-URL: #67113
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Tim Perry <[email protected]>
aduh95 pushed a commit that referenced this pull request Nov 17, 2026
@inoway46 @aduh95
http2: exclude queued data from response memory checks
46ff0d9
Allow clients to receive responses when queued request data exceeds
maxSessionMemory, while preserving limits on received headers.

Fixes: #66739
Refs: #67113
Assisted-by: Codex
Signed-off-by: inoway46 <[email protected]>
PR-URL: #67114
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Tim Perry <[email protected]>
@github-actions github-actions Bot mentioned this pull request Nov 20, 2026
2026-11-30, Version 26.14.0 'Lithium' (LTS) #67664
Open
@aduh95 aduh95 removed the lts-watch-v26.x PRs that may need to be released in v26.x. label Nov 20, 2026
@aduh95 aduh95 mentioned this pull request Nov 21, 2026
2026-11-30, Version 24.23.0 'Krypton' (LTS) #67663
Open
@aduh95 aduh95 removed the lts-watch-v24.x PRs that may need to be released in v24.x label Nov 21, 2026
Renegade334 pushed a commit to Renegade334/node that referenced this pull request Nov 21, 2026
@inoway46 @aduh95
http2: release queued data memory on stream cancellation
014c1e7
Release the memory charged for queued outbound data when a stream is
canceled, so subsequent requests can reuse the session's memory budget.

Refs: nodejs#66739
Assisted-by: Codex
Signed-off-by: inoway46 <[email protected]>
PR-URL: nodejs#67113
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Tim Perry <[email protected]>
@Dr-Nikson Dr-Nikson mentioned this pull request Nov 25, 2026
fix(server): answer malformed authorities, serve Node's IPv6 form, and cap request size Dr-Nikson/effect-grpc#84
Merged
Dr-Nikson added a commit to Dr-Nikson/effect-grpc that referenced this pull request Nov 25, 2026
@Dr-Nikson
feat(server): cap request messages at 4 MiB, settable with readMaxBytes
9625162
The server passed no read limit to Connect, so Connect's default of
about 4 GiB per message applied. build() now takes GrpcServerOptions,
whose readMaxBytes sets the largest request message the server reads.
It defaults to 4 MiB, as in grpc-go and grpc-js. Connect checks the
limit on the wire and again after decompression, and answers a larger
message with RESOURCE_EXHAUSTED on every route.

The option is there because the operator asked on PR #84 to "make it
configurable now, with one server option (for example `readMaxBytes`,
default 4 MiB)":
#84 (comment)
The other server options that #74 asks for can join the same object.

Connect stops reading a message it refuses. A Node client without the
HTTP/2 fixes from nodejs/node#67113 and nodejs/node#67114 keeps the
unsent rest queued on its connection, and after about 10 MB of refused
uploads every later call on that connection fails.

Refs #61
Dr-Nikson added a commit to Dr-Nikson/effect-grpc that referenced this pull request Nov 25, 2026
@Dr-Nikson
feat(verify): check hostile requests from the fixture and launch on ::1
a990ae5
hostile-authority now runs scripts/hostile-requests.mjs, which sends
every authority case in the e2e fixture over gRPC and Connect with
Node's HTTP/2 client and follows each case with a normal call. The new
message-limit command sends messages of 4 MiB, 4 MiB + 1 byte and
5 MiB, then a normal call over each protocol. Each command passes only
when every check passes and the server is still alive.

message-limit sends each oversized message on a connection of its own.
A Node client without nodejs/node#67113 and nodejs/node#67114 keeps the
unsent rest of each refused upload: with all three on one connection,
the third oversized message and every later call got rstCode 11.

launch --host ::1 binds the example to ::1 through the new
EFFECT_GRPC_EXAMPLE_HOST variable, so probe can call the generated
client at http://[::1]:<port>. Each evidence file records the exact
driver command, and the docs describe the new pass conditions and drop
the known failure for the IPv6 authority.

Refs #61
@Dr-Nikson Dr-Nikson mentioned this pull request Nov 25, 2026
Server: a refused upload to a streaming, unimplemented or unknown method can break a Node client's connection Dr-Nikson/effect-grpc#105
Closed
4 tasks
@github-actions github-actions Bot mentioned this pull request Nov 27, 2026
chore: version packages (alpha) Dr-Nikson/effect-grpc#128
Open
gabylb pushed a commit to gabylb/node that referenced this pull request Nov 27, 2026
@inoway46 @gabylb
http2: release queued data memory on stream cancellation
c49c7ef
Release the memory charged for queued outbound data when a stream is
canceled, so subsequent requests can reuse the session's memory budget.

Refs: nodejs#66739
Assisted-by: Codex
Signed-off-by: inoway46 <[email protected]>
PR-URL: nodejs#67113
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Tim Perry <[email protected]>
gabylb pushed a commit to gabylb/node that referenced this pull request Nov 27, 2026
@inoway46 @gabylb
http2: exclude queued data from response memory checks
a1fbb60
Allow clients to receive responses when queued request data exceeds
maxSessionMemory, while preserving limits on received headers.

Fixes: nodejs#66739
Refs: nodejs#67113
Assisted-by: Codex
Signed-off-by: inoway46 <[email protected]>
PR-URL: nodejs#67114
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Tim Perry <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina approved these changes
@pimterry pimterry pimterry approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. http2 Issues and PRs related to the http2 subsystem. lts-watch-v22.x PRs that may need to be released in v22.x

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@inoway46 @nodejs-github-bot @mishushakov @mcollina @pimterry @aduh95
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.