镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

http2: add new connectionWindowSize option - #65619

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
pimterry:http2-connection-window-size-option
Sep 9, 2026
Merged

nodejs-github-bot merged 1 commit into
nodejs:mainfrom
pimterry:http2-connection-window-size-option

Conversation

@pimterry

Copy link
Copy Markdown
Member

#64623 massively increased the default HTTP/2 connection window size from 64KB bytes to 32MB.

This is definitely a good thing for bandwidth in common scenarios, but there's no way for users to opt-out of this change or to shrink the window themselves for other use cases.

That limitation is because the only way to change this today is through setLocalWindowSize, which is only available for dynamic changes after connection setup. Unfortunately, once an HTTP/2 connection is set up it's impossible to shrink the initial window back below the advertised amount (impossible in the protocol, not just our implementation), so changes only apply once the initial window has been used up. With a default of 32MB per session, that can take a while.

Shrinking the window can be useful as a quick workaround to preserve old behaviour, or to optimize for low-latency connections or constrained memory environments, where you want smaller buffers & more responsive backpressure instead of a huge window optimized for throughput over high-latency.

This PR adds a new HTTP/2 connectionWindowSize option to let you configure the initial connection window. If set, it overrides the initial window that's configured on nghttp2 before the session connects.

En route this also commonizes some option validation into validateSessionOptions, deduplicating some existing validation and giving a single place to add the validation for this new option.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/http2
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. labels Aug 28, 2026
Signed-off-by: Tim Perry <pimterry@gmail.com>
@pimterry
pimterry force-pushed the http2-connection-window-size-option branch from 6e6d342 to 137d777 Compare August 28, 2026 15:17
@codecov

codecov Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.06%. Comparing base (d6e67a5) to head (137d777).
⚠️ Report is 281 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65619      +/-   ##
==========================================
- Coverage   90.07%   90.06%   -0.01%     
==========================================
  Files         751      751              
  Lines      254881   254932      +51     
  Branches    48111    48124      +13     
==========================================
+ Hits       229582   229603      +21     
- Misses      16486    16496      +10     
- Partials     8813     8833      +20     
Files with missing lines Coverage Δ
lib/internal/http2/core.js 95.10% <100.00%> (+0.02%) ⬆️
lib/internal/http2/util.js 92.93% <100.00%> (+0.04%) ⬆️
src/node_http2.cc 81.87% <100.00%> (+0.03%) ⬆️
src/node_http2.h 92.39% <100.00%> (+0.16%) ⬆️
src/node_http2_state.h 100.00% <ø> (ø)

... 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.

@pimterry
pimterry requested a review from mcollina September 8, 2026 10:31

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@pimterry pimterry 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 Sep 8, 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 Sep 8, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@pimterry pimterry added the commit-queue PRs queued for automated landing through the Commit Queue. label Sep 9, 2026
@nodejs-github-bot
nodejs-github-bot merged commit b12688c into nodejs:main Sep 9, 2026
72 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in b12688c

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Sep 9, 2026
@aduh95 aduh95 added the backport-requested-v26.x PRs awaiting manual backport to the v26.x-staging branch. label Sep 18, 2026
@aduh95

aduh95 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

This does land cleanly on v26.x-staging, can you please open a manual backport PR?

@pimterry pimterry added backport-open-v26.x Indicate that the PR has an open backport and removed backport-requested-v26.x PRs awaiting manual backport to the v26.x-staging branch. labels Sep 21, 2026
@pimterry
pimterry deleted the http2-connection-window-size-option branch September 21, 2026 07:32
@richardlau richardlau added the semver-minor PRs that contain new features and should be released in the next minor version. label Sep 29, 2026
pimterry added a commit that referenced this pull request Oct 5, 2026
Signed-off-by: Tim Perry <pimterry@gmail.com>
PR-URL: #65619
Backport-PR-URL: #66167
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
@pimterry pimterry added backported-to-v26.x PRs backported to the v26.x-staging branch. and removed backport-open-v26.x Indicate that the PR has an open backport labels Oct 5, 2026
nodejs-github-bot added a commit that referenced this pull request Oct 5, 2026
Notable changes:

benchmark:
  * (SEMVER-MINOR) add http header validator benchmark (James M Snell) #66334
buffer:
  * (SEMVER-MINOR) add isLatin1 (James M Snell) #66298
  * (SEMVER-MINOR) add isLatin1 (James M Snell) #66298
  * (SEMVER-MINOR) add Buffer.stringLength() (Matteo Collina) #66064
build, doc:
  * move to redesign (Aviv Keller) #62045
http:
  * (SEMVER-MINOR) add isValidHeaderName() and isValidHeaderValue() (James M Snell) #66334
http2:
  * (SEMVER-MINOR) add new connectionWindowSize option (Tim Perry) #65619
lib:
  * (SEMVER-MINOR) fix stream loading bug in node:bench (James M Snell) #66114
perf_hooks:
  * (SEMVER-MINOR) fix truncation of monitorEventLoopDelay() resolution (James M Snell) #66115
  * (SEMVER-MINOR) allow RecordableHistogram to record 0 (James M Snell) #66114
  * (SEMVER-MINOR) add histogram.diff() (James M Snell) #66099
  * (SEMVER-MINOR) report histogram memory to V8 (James M Snell) #66099
  * (SEMVER-MINOR) add histogram.snapshot() (James M Snell) #66099
  * (SEMVER-MINOR) add histogram export format version 2 (James M Snell) #66098
  * (SEMVER-MINOR) harden histogram CBOR import validation (James M Snell) #66098
process:
  * (SEMVER-MINOR) graduate process.ref/unref from experimental (James M Snell) #66213
sqlite:
  * (SEMVER-MINOR) rename DatabaseSync and StatementSync (Guilherme Araújo) #65988
src:
  * (SEMVER-MINOR) add --process-timeout=N (James M Snell) #66138
  * (SEMVER-MINOR) expose size and count in heap profile output (Ilyas Shabi) #65737
  * (SEMVER-MINOR) let embedders exempt linked bindings from the addon permission (Shelley Vohr) #66067
test:
  * deflake sliding window histogram test (James M Snell) #66132

PR-URL: #66546
@aduh95

aduh95 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Something I'm noticing while working on the changelog for the new release: we usually prefer add instead of add new in the commit message, new is not only redundant but also a JS keyword so I find the wording confusing.

aduh95 pushed a commit that referenced this pull request Oct 6, 2026
Notable changes:

buffer:
  * (SEMVER-MINOR) add isLatin1 (James M Snell) #66298
  * (SEMVER-MINOR) add Buffer.stringLength() (Matteo Collina) #66064
build, doc:
  * move to redesign (Aviv Keller) #62045
http:
  * (SEMVER-MINOR) add isValidHeaderName() and isValidHeaderValue() (James M Snell) #66334
http2:
  * (SEMVER-MINOR) add new connectionWindowSize option (Tim Perry) #65619
perf_hooks:
  * (SEMVER-MINOR) fix truncation of monitorEventLoopDelay() resolution (James M Snell) #66115
  * (SEMVER-MINOR) allow RecordableHistogram to record 0 (James M Snell) #66114
  * (SEMVER-MINOR) add histogram.diff() (James M Snell) #66099
  * (SEMVER-MINOR) report histogram memory to V8 (James M Snell) #66099
  * (SEMVER-MINOR) add histogram.snapshot() (James M Snell) #66099
  * (SEMVER-MINOR) add histogram export format version 2 (James M Snell) #66098
  * (SEMVER-MINOR) harden histogram CBOR import validation (James M Snell) #66098
process:
  * (SEMVER-MINOR) graduate process.ref/unref from experimental (James M Snell) #66213
sqlite:
  * (SEMVER-MINOR) rename DatabaseSync and StatementSync (Guilherme Araújo) #65988
src:
  * (SEMVER-MINOR) add --process-timeout=N (James M Snell) #66138
  * (SEMVER-MINOR) expose size and count in heap profile output (Ilyas Shabi) #65737
  * (SEMVER-MINOR) let embedders exempt linked bindings from the addon permission (Shelley Vohr) #66067

PR-URL: #66546
aduh95 pushed a commit that referenced this pull request Oct 6, 2026
Notable changes:

buffer:
  * (SEMVER-MINOR) add isLatin1 (James M Snell) #66298
  * (SEMVER-MINOR) add Buffer.stringLength() (Matteo Collina) #66064
build, doc:
  * move to redesign (Aviv Keller) #62045
doc:
  * promote Alpine Linux to tier 2 support (Stewart X Addison) #63737
http:
  * (SEMVER-MINOR) add isValidHeaderName() and isValidHeaderValue() (James M Snell) #66334
http2:
  * (SEMVER-MINOR) add new connectionWindowSize option (Tim Perry) #65619
perf_hooks:
  * (SEMVER-MINOR) fix truncation of monitorEventLoopDelay() resolution (James M Snell) #66115
  * (SEMVER-MINOR) allow RecordableHistogram to record 0 (James M Snell) #66114
  * (SEMVER-MINOR) add histogram.diff() (James M Snell) #66099
  * (SEMVER-MINOR) add histogram.snapshot() (James M Snell) #66099
  * (SEMVER-MINOR) harden histogram CBOR import validation (James M Snell) #66098
process:
  * (SEMVER-MINOR) graduate process.ref/unref from experimental (James M Snell) #66213
sqlite:
  * (SEMVER-MINOR) rename DatabaseSync and StatementSync (Guilherme Araújo) #65988
src:
  * (SEMVER-MINOR) add --process-timeout=N (James M Snell) #66138
  * (SEMVER-MINOR) expose size and count in heap profile output (Ilyas Shabi) #65737
  * (SEMVER-MINOR) let embedders exempt linked bindings from the addon permission (Shelley Vohr) #66067

PR-URL: #66546
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backported-to-v26.x PRs backported to the v26.x-staging branch. c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants