Skip to content

http2: add new connectionWindowSize option - #65619

Open
pimterry wants to merge 1 commit into
nodejs:mainfrom
pimterry:http2-connection-window-size-option
Open

http2: add new connectionWindowSize option#65619
pimterry wants to merge 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 15 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants