http2: increase default window sizes - #64623

Merged
nodejs-github-bot merged 5 commits into
nodejs:mainfrom
mcollina:increase-http2-window-size
Aug 4, 2026
Merged

http2: increase default window sizes#64623
nodejs-github-bot merged 5 commits into
nodejs:mainfrom
mcollina:increase-http2-window-size

Conversation

@mcollina

Copy link
Copy Markdown
Member

Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).

The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.

Fixes#38426

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

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

@nodejs-github-botnodejs-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 Jul 20, 2026
@mcollina
mcollina requested review from pimterry, ronag and trivikr and removed request for pimterryJuly 20, 2026 12:33
Comment threadsrc/node_http2.cc Outdated
// to window_size / RTT. With a 32MB connection window, throughput is
// significantly improved. See https://github.com/nodejs/node/issues/38426
CHECK_EQ(nghttp2_session_set_local_window_size(
session, NGHTTP2_FLAG_NONE, 0, 33554432), 0);

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.

There's a pre-existing issue that this exposes: you can't configure this in advance. You can only control the connection window with session.setLocalWindowSize once you have a session, but at that point this initial WINDOW_UPDATE has already been sent, and shrinking the window isn't effective as shown in the tests here (it just blocks further updates, it can't reduce what's already been sent). The stream window is configurable in advance (it's a SETTINGS parameter) but this connection window isn't.

That already existed implicitly but it was kind of OK when the initial window was small, but it's a real problem with a very large initial window I think, since there's basically no way to override this to make it any smaller again if you need to.

Can we add client & server options for this, so it can be configured before the first WINDOW_UPDATE is sent somehow?

Comment threadsrc/node_http2.cc Outdated
// to window_size / RTT. With a 32MB connection window, throughput is
// significantly improved. See https://github.com/nodejs/node/issues/38426
CHECK_EQ(nghttp2_session_set_local_window_size(
session, NGHTTP2_FLAG_NONE, 0, 33554432), 0);

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.

Nit: would be nicer to extract this as a constant

@codecov

codecovBot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.55556% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.16%. Comparing base (c8e2a82) to head (f399373).
⚠️ Report is 90 commits behind head on main.

Files with missing linesPatch %Lines
src/stream_pipe.cc0.00%4 Missing and 1 partial ⚠️
src/stream_base.cc0.00%0 Missing and 2 partials ⚠️
src/node_http2.cc0.00%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #64623 +/- ##
==========================================
- Coverage 90.16% 90.16% -0.01% 
==========================================
Files 746 746 Lines 242760 242773 +13 Branches 45765 45766 +1 ==========================================
+ Hits 218875 218885 +10 + Misses 15375 15368 -7 - Partials 8510 8520 +10 
Files with missing linesCoverage Δ
lib/internal/http2/core.js95.07% <100.00%> (+0.01%)⬆️
src/node_http2.h92.26% <ø> (ø)
src/node_http2.cc81.66% <0.00%> (-0.09%)⬇️
src/stream_base.cc79.74% <0.00%> (-0.30%)⬇️
src/stream_pipe.cc56.48% <0.00%> (-3.06%)⬇️

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

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch 2 times, most recently from 5c9bc03 to 4351b51CompareJuly 20, 2026 16:48
@mcollina

Copy link
Copy Markdown
MemberAuthor

Both addressed:

  1. Extracted DEFAULT_SETTINGS_LOCAL_CONNECTION_WINDOW_SIZE = 33554432 as a named constant in src/node_http2.h and used it in src/node_http2.cc.
  2. The pre-existing issue about not being able to configure the connection window in advance is noted — the initial WINDOW_UPDATE is sent at session creation before setLocalWindowSize can be called. This is a known limitation of the current API.

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from 4351b51 to 31761a0CompareJuly 20, 2026 18:25

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

Wouldn't it be semver-majorPRs that contain breaking changes and should be released in the next major version. ?

@mcollinamcollina added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jul 20, 2026
@mcollina

Copy link
Copy Markdown
MemberAuthor

yes

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch 3 times, most recently from 70882db to bd4cbd3CompareJuly 21, 2026 16:44
@pimterry

Copy link
Copy Markdown
Member

The pre-existing issue about not being able to configure the connection window in advance is noted — the initial WINDOW_UPDATE is sent at session creation before setLocalWindowSize can be called. This is a known limitation of the current API.

I do think this would be useful, but doesn't need to block this - I'll open a separate PR.

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from bd4cbd3 to 86b969bCompareJuly 21, 2026 22:16
@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from 86b969b to d0c68baCompareJuly 22, 2026 09:39

@Ethan-ArrowoodEthan-Arrowood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CI failure seems related to the change here; test-http2-respond-with-file-connection-abort is failing across multiple systems and that isn't a known flake. Leaving a request changes to this gets fixed before landing.

When a stream is destroyed while a synchronous write is in flight
from StreamPipe::ProcessData, ReportWritesToJSStreamListener::
OnStreamAfterReqFinished can be called with a null stream_ or a
null req_wrap, causing a null pointer dereference. This race
becomes more likely with larger HTTP/2 windows (e.g., nodejs#38426)
because more data is in flight during session teardown.
Add early-return guards for both cases to prevent the crash.
Refs: nodejs#38426
Refs: nodejs#56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
With the default window size increase, the server sends an additional
WINDOW_UPDATE frame during session setup, increasing the frames received
by the client from 7 to 8 on some platforms. Relax the assertion to
check >= 7 instead of strict equality.
Refs: nodejs#38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
When the writable sink is destroyed while there are still pending
writes, WritableListener::OnStreamDestroy previously reset
pending_writes_ to 0. This caused OnStreamAfterWrite to decrement
the counter below 0, making the pending_writes_ == 0 completion
check fail permanently — the oncomplete callback was never called,
causing a timeout.
Fix by:
1. Not resetting pending_writes_ in OnStreamDestroy — let
OnStreamAfterWrite track completion naturally.
2. Using sink_destroyed_ flag in Unpipe to always remove the
writable listener regardless of pending_writes_ count.
3. Using <= 0 (instead of == 0) when sink_destroyed_ is set,
and guarding RemoveStreamListener against a null stream.
This race became more likely with larger HTTP/2 windows (nodejs#38426)
because more writes are in flight when session teardown begins.
Refs: nodejs#38426
Refs: nodejs#56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from a25a676 to f399373CompareJuly 30, 2026 21:20
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 2, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mcollinamcollina added commit-queue PRs queued for automated landing through the Commit Queue. and removed needs-ci PRs that need a full CI run. labels Aug 3, 2026
@nodejs-github-botnodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Aug 3, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/64623
✔ Done loading data for nodejs/node/pull/64623
----------------------------------- PR info ------------------------------------
Title http2: increase default window sizes (#64623)
Author Matteo Collina <matteo.collina@gmail.com> (@mcollina)
Branch mcollina:increase-http2-window-size -> nodejs:main
Labels c++, semver-major, lib / src
Commits 5
- http2: increase default window sizes
- http2: guard against null stream/req in OnStreamAfterReqFinished
- http2: relax framesReceived assertion in perf_hooks test
- stream: fix pending_writes underflow in StreamPipe shutdown
- style: fix clang-format alignment in CHECK_EQ call
Committers 1
- Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
--------------------------------------------------------------------------------
ℹ This PR was created on Mon, 20 Jul 2026 12:33:00 GMT
✔ Approvals: 8
✔ - Rafael Gonzaga (@RafaelGSS) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4737957628
✔ - Tim Perry (@pimterry): https://github.com/nodejs/node/pull/64623#pullrequestreview-4765202215
✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4749623762
✔ - Gürgün Dayıoğlu (@gurgunday): https://github.com/nodejs/node/pull/64623#pullrequestreview-4765616109
✔ - Ethan Arrowood (@Ethan-Arrowood): https://github.com/nodejs/node/pull/64623#pullrequestreview-4767534645
✔ - Aviv Keller (@avivkeller): https://github.com/nodejs/node/pull/64623#pullrequestreview-4770440465
✔ - Robert Nagy (@ronag) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4838488304
✔ - Trivikram Kamat (@trivikr): https://github.com/nodejs/node/pull/64623#pullrequestreview-4841424027
✔ Last GitHub CI successful
ℹ Last Full PR CI on 2026-08-03T12:22:08Z: https://ci.nodejs.org/job/node-test-pull-request/75428/
- Querying data for job/node-test-pull-request/75428/
✔ Build data downloaded
✔ Last Jenkins CI successful
--------------------------------------------------------------------------------
✔ No git cherry-pick in progress
✔ No git am in progress
✔ No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
* branch main -> FETCH_HEAD
✔ origin/main is now up-to-date
- Downloading patch for 64623
From https://github.com/nodejs/node
* branch refs/pull/64623/merge -> FETCH_HEAD
✔ Fetched commits as 7e439828de88..f3993733daf8
--------------------------------------------------------------------------------
Auto-merging doc/api/http2.md
[main d458cadee7] http2: increase default window sizes
Author: Matteo Collina <hello@matteocollina.com>
Date: Mon Jul 20 12:09:08 2026 +0000
16 files changed, 78 insertions(+), 61 deletions(-)
[main 2e28518bd9] http2: guard against null stream/req in OnStreamAfterReqFinished
Author: Matteo Collina <hello@matteocollina.com>
Date: Thu Jul 23 14:28:24 2026 +0000
1 file changed, 2 insertions(+)
[main 8974b46a94] http2: relax framesReceived assertion in perf_hooks test
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 08:19:42 2026 +0000
1 file changed, 5 insertions(+), 1 deletion(-)
[main 83d3ac6cb0] stream: fix pending_writes underflow in StreamPipe shutdown
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 11:03:27 2026 +0000
1 file changed, 13 insertions(+), 4 deletions(-)
[main 93ebe33adb] style: fix clang-format alignment in CHECK_EQ call
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 15:10:46 2026 +0000
1 file changed, 3 insertions(+), 5 deletions(-)
✔ Patches applied
There are 5 commits in the PR. Attempting autorebase.
(node:365) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Rebasing (2/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: increase default window sizes

Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).

The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.

Fixes: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 221808bb0e] http2: increase default window sizes
Author: Matteo Collina <hello@matteocollina.com>
Date: Mon Jul 20 12:09:08 2026 +0000
16 files changed, 78 insertions(+), 61 deletions(-)
Rebasing (3/10)
Rebasing (4/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: guard against null stream/req in OnStreamAfterReqFinished

When a stream is destroyed while a synchronous write is in flight
from StreamPipe::ProcessData, ReportWritesToJSStreamListener::
OnStreamAfterReqFinished can be called with a null stream_ or a
null req_wrap, causing a null pointer dereference. This race
becomes more likely with larger HTTP/2 windows (e.g., #38426)
because more data is in flight during session teardown.

Add early-return guards for both cases to prevent the crash.

Refs: #38426
Refs: #56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 83b091065d] http2: guard against null stream/req in OnStreamAfterReqFinished
Author: Matteo Collina <hello@matteocollina.com>
Date: Thu Jul 23 14:28:24 2026 +0000
1 file changed, 2 insertions(+)
Rebasing (5/10)
Rebasing (6/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: relax framesReceived assertion in perf_hooks test

With the default window size increase, the server sends an additional
WINDOW_UPDATE frame during session setup, increasing the frames received
by the client from 7 to 8 on some platforms. Relax the assertion to
check >= 7 instead of strict equality.

Refs: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 4a7c271e8b] http2: relax framesReceived assertion in perf_hooks test
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 08:19:42 2026 +0000
1 file changed, 5 insertions(+), 1 deletion(-)
Rebasing (7/10)
Rebasing (8/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
stream: fix pending_writes underflow in StreamPipe shutdown

When the writable sink is destroyed while there are still pending
writes, WritableListener::OnStreamDestroy previously reset
pending_writes_ to 0. This caused OnStreamAfterWrite to decrement
the counter below 0, making the pending_writes_ == 0 completion
check fail permanently — the oncomplete callback was never called,
causing a timeout.

Fix by:

  1. Not resetting pending_writes_ in OnStreamDestroy — let
    OnStreamAfterWrite track completion naturally.
  2. Using sink_destroyed_ flag in Unpipe to always remove the
    writable listener regardless of pending_writes_ count.
  3. Using <= 0 (instead of == 0) when sink_destroyed_ is set,
    and guarding RemoveStreamListener against a null stream.

This race became more likely with larger HTTP/2 windows (#38426)
because more writes are in flight when session teardown begins.

Refs: #38426
Refs: #56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 9d0e7f3fd7] stream: fix pending_writes underflow in StreamPipe shutdown
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 11:03:27 2026 +0000
1 file changed, 13 insertions(+), 4 deletions(-)
Rebasing (9/10)
Rebasing (10/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
style: fix clang-format alignment in CHECK_EQ call

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 6cbbcc670b] style: fix clang-format alignment in CHECK_EQ call
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 15:10:46 2026 +0000
1 file changed, 3 insertions(+), 5 deletions(-)
Successfully rebased and updated refs/heads/main.

ℹ Add commit-queue-squash label to land the PR as one commit, or commit-queue-rebase to land as separate commits.

https://github.com/nodejs/node/actions/runs/30825144898

@trivikrtrivikr removed the commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. label Aug 3, 2026
@trivikr

Copy link
Copy Markdown
Member

@mcollina This either needs commit-queue-squash or commit-queue-rebase

@mcollinamcollina added commit-queue-squash PRs the Commit Queue should land as one squashed commit. commit-queue PRs queued for automated landing through the Commit Queue. labels Aug 3, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 3, 2026
@aduh95aduh95 added the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 4, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 4, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 1576cb8 into nodejs:mainAug 4, 2026
82 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 1576cb8

aduh95 pushed a commit that referenced this pull request Aug 13, 2026
Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).
The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.
Fixes: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Sign up for freeto 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++.commit-queue-squashPRs the Commit Queue should land as one squashed commit.lib / srcIssues and PRs involving general changes in the lib/ or src/ directories.semver-majorPRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase HTTP/2 window size by default

13 participants

@mcollina@nodejs-github-bot@pimterry@Ethan-Arrowood@trivikr@jasnell@ronag@metcoder95@RafaelGSS@avivkeller@gurgunday@bjohansebas@aduh95
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

http2: increase default window sizes - #64623

Merged
nodejs-github-bot merged 5 commits into
nodejs:mainfrom
mcollina:increase-http2-window-size
Aug 4, 2026
Merged

http2: increase default window sizes#64623
nodejs-github-bot merged 5 commits into
nodejs:mainfrom
mcollina:increase-http2-window-size

Conversation

@mcollina

Copy link
Copy Markdown
Member

Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).

The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.

Fixes#38426

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

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

@nodejs-github-botnodejs-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 Jul 20, 2026
@mcollina
mcollina requested review from pimterry, ronag and trivikr and removed request for pimterryJuly 20, 2026 12:33
Comment threadsrc/node_http2.cc Outdated
// to window_size / RTT. With a 32MB connection window, throughput is
// significantly improved. See https://github.com/nodejs/node/issues/38426
CHECK_EQ(nghttp2_session_set_local_window_size(
session, NGHTTP2_FLAG_NONE, 0, 33554432), 0);

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.

There's a pre-existing issue that this exposes: you can't configure this in advance. You can only control the connection window with session.setLocalWindowSize once you have a session, but at that point this initial WINDOW_UPDATE has already been sent, and shrinking the window isn't effective as shown in the tests here (it just blocks further updates, it can't reduce what's already been sent). The stream window is configurable in advance (it's a SETTINGS parameter) but this connection window isn't.

That already existed implicitly but it was kind of OK when the initial window was small, but it's a real problem with a very large initial window I think, since there's basically no way to override this to make it any smaller again if you need to.

Can we add client & server options for this, so it can be configured before the first WINDOW_UPDATE is sent somehow?

Comment threadsrc/node_http2.cc Outdated
// to window_size / RTT. With a 32MB connection window, throughput is
// significantly improved. See https://github.com/nodejs/node/issues/38426
CHECK_EQ(nghttp2_session_set_local_window_size(
session, NGHTTP2_FLAG_NONE, 0, 33554432), 0);

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.

Nit: would be nicer to extract this as a constant

@codecov

codecovBot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.55556% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.16%. Comparing base (c8e2a82) to head (f399373).
⚠️ Report is 90 commits behind head on main.

Files with missing linesPatch %Lines
src/stream_pipe.cc0.00%4 Missing and 1 partial ⚠️
src/stream_base.cc0.00%0 Missing and 2 partials ⚠️
src/node_http2.cc0.00%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #64623 +/- ##
==========================================
- Coverage 90.16% 90.16% -0.01% 
==========================================
Files 746 746 Lines 242760 242773 +13 Branches 45765 45766 +1 ==========================================
+ Hits 218875 218885 +10 + Misses 15375 15368 -7 - Partials 8510 8520 +10 
Files with missing linesCoverage Δ
lib/internal/http2/core.js95.07% <100.00%> (+0.01%)⬆️
src/node_http2.h92.26% <ø> (ø)
src/node_http2.cc81.66% <0.00%> (-0.09%)⬇️
src/stream_base.cc79.74% <0.00%> (-0.30%)⬇️
src/stream_pipe.cc56.48% <0.00%> (-3.06%)⬇️

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

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch 2 times, most recently from 5c9bc03 to 4351b51CompareJuly 20, 2026 16:48
@mcollina

Copy link
Copy Markdown
MemberAuthor

Both addressed:

  1. Extracted DEFAULT_SETTINGS_LOCAL_CONNECTION_WINDOW_SIZE = 33554432 as a named constant in src/node_http2.h and used it in src/node_http2.cc.
  2. The pre-existing issue about not being able to configure the connection window in advance is noted — the initial WINDOW_UPDATE is sent at session creation before setLocalWindowSize can be called. This is a known limitation of the current API.

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from 4351b51 to 31761a0CompareJuly 20, 2026 18:25

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

Wouldn't it be semver-majorPRs that contain breaking changes and should be released in the next major version. ?

@mcollinamcollina added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jul 20, 2026
@mcollina

Copy link
Copy Markdown
MemberAuthor

yes

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch 3 times, most recently from 70882db to bd4cbd3CompareJuly 21, 2026 16:44
@pimterry

Copy link
Copy Markdown
Member

The pre-existing issue about not being able to configure the connection window in advance is noted — the initial WINDOW_UPDATE is sent at session creation before setLocalWindowSize can be called. This is a known limitation of the current API.

I do think this would be useful, but doesn't need to block this - I'll open a separate PR.

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from bd4cbd3 to 86b969bCompareJuly 21, 2026 22:16
@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from 86b969b to d0c68baCompareJuly 22, 2026 09:39

@Ethan-ArrowoodEthan-Arrowood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CI failure seems related to the change here; test-http2-respond-with-file-connection-abort is failing across multiple systems and that isn't a known flake. Leaving a request changes to this gets fixed before landing.

When a stream is destroyed while a synchronous write is in flight
from StreamPipe::ProcessData, ReportWritesToJSStreamListener::
OnStreamAfterReqFinished can be called with a null stream_ or a
null req_wrap, causing a null pointer dereference. This race
becomes more likely with larger HTTP/2 windows (e.g., nodejs#38426)
because more data is in flight during session teardown.
Add early-return guards for both cases to prevent the crash.
Refs: nodejs#38426
Refs: nodejs#56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
With the default window size increase, the server sends an additional
WINDOW_UPDATE frame during session setup, increasing the frames received
by the client from 7 to 8 on some platforms. Relax the assertion to
check >= 7 instead of strict equality.
Refs: nodejs#38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
When the writable sink is destroyed while there are still pending
writes, WritableListener::OnStreamDestroy previously reset
pending_writes_ to 0. This caused OnStreamAfterWrite to decrement
the counter below 0, making the pending_writes_ == 0 completion
check fail permanently — the oncomplete callback was never called,
causing a timeout.
Fix by:
1. Not resetting pending_writes_ in OnStreamDestroy — let
OnStreamAfterWrite track completion naturally.
2. Using sink_destroyed_ flag in Unpipe to always remove the
writable listener regardless of pending_writes_ count.
3. Using <= 0 (instead of == 0) when sink_destroyed_ is set,
and guarding RemoveStreamListener against a null stream.
This race became more likely with larger HTTP/2 windows (nodejs#38426)
because more writes are in flight when session teardown begins.
Refs: nodejs#38426
Refs: nodejs#56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from a25a676 to f399373CompareJuly 30, 2026 21:20
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 2, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mcollinamcollina added commit-queue PRs queued for automated landing through the Commit Queue. and removed needs-ci PRs that need a full CI run. labels Aug 3, 2026
@nodejs-github-botnodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Aug 3, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/64623
✔ Done loading data for nodejs/node/pull/64623
----------------------------------- PR info ------------------------------------
Title http2: increase default window sizes (#64623)
Author Matteo Collina <matteo.collina@gmail.com> (@mcollina)
Branch mcollina:increase-http2-window-size -> nodejs:main
Labels c++, semver-major, lib / src
Commits 5
- http2: increase default window sizes
- http2: guard against null stream/req in OnStreamAfterReqFinished
- http2: relax framesReceived assertion in perf_hooks test
- stream: fix pending_writes underflow in StreamPipe shutdown
- style: fix clang-format alignment in CHECK_EQ call
Committers 1
- Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
--------------------------------------------------------------------------------
ℹ This PR was created on Mon, 20 Jul 2026 12:33:00 GMT
✔ Approvals: 8
✔ - Rafael Gonzaga (@RafaelGSS) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4737957628
✔ - Tim Perry (@pimterry): https://github.com/nodejs/node/pull/64623#pullrequestreview-4765202215
✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4749623762
✔ - Gürgün Dayıoğlu (@gurgunday): https://github.com/nodejs/node/pull/64623#pullrequestreview-4765616109
✔ - Ethan Arrowood (@Ethan-Arrowood): https://github.com/nodejs/node/pull/64623#pullrequestreview-4767534645
✔ - Aviv Keller (@avivkeller): https://github.com/nodejs/node/pull/64623#pullrequestreview-4770440465
✔ - Robert Nagy (@ronag) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4838488304
✔ - Trivikram Kamat (@trivikr): https://github.com/nodejs/node/pull/64623#pullrequestreview-4841424027
✔ Last GitHub CI successful
ℹ Last Full PR CI on 2026-08-03T12:22:08Z: https://ci.nodejs.org/job/node-test-pull-request/75428/
- Querying data for job/node-test-pull-request/75428/
✔ Build data downloaded
✔ Last Jenkins CI successful
--------------------------------------------------------------------------------
✔ No git cherry-pick in progress
✔ No git am in progress
✔ No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
* branch main -> FETCH_HEAD
✔ origin/main is now up-to-date
- Downloading patch for 64623
From https://github.com/nodejs/node
* branch refs/pull/64623/merge -> FETCH_HEAD
✔ Fetched commits as 7e439828de88..f3993733daf8
--------------------------------------------------------------------------------
Auto-merging doc/api/http2.md
[main d458cadee7] http2: increase default window sizes
Author: Matteo Collina <hello@matteocollina.com>
Date: Mon Jul 20 12:09:08 2026 +0000
16 files changed, 78 insertions(+), 61 deletions(-)
[main 2e28518bd9] http2: guard against null stream/req in OnStreamAfterReqFinished
Author: Matteo Collina <hello@matteocollina.com>
Date: Thu Jul 23 14:28:24 2026 +0000
1 file changed, 2 insertions(+)
[main 8974b46a94] http2: relax framesReceived assertion in perf_hooks test
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 08:19:42 2026 +0000
1 file changed, 5 insertions(+), 1 deletion(-)
[main 83d3ac6cb0] stream: fix pending_writes underflow in StreamPipe shutdown
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 11:03:27 2026 +0000
1 file changed, 13 insertions(+), 4 deletions(-)
[main 93ebe33adb] style: fix clang-format alignment in CHECK_EQ call
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 15:10:46 2026 +0000
1 file changed, 3 insertions(+), 5 deletions(-)
✔ Patches applied
There are 5 commits in the PR. Attempting autorebase.
(node:365) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Rebasing (2/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: increase default window sizes

Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).

The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.

Fixes: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 221808bb0e] http2: increase default window sizes
Author: Matteo Collina <hello@matteocollina.com>
Date: Mon Jul 20 12:09:08 2026 +0000
16 files changed, 78 insertions(+), 61 deletions(-)
Rebasing (3/10)
Rebasing (4/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: guard against null stream/req in OnStreamAfterReqFinished

When a stream is destroyed while a synchronous write is in flight
from StreamPipe::ProcessData, ReportWritesToJSStreamListener::
OnStreamAfterReqFinished can be called with a null stream_ or a
null req_wrap, causing a null pointer dereference. This race
becomes more likely with larger HTTP/2 windows (e.g., #38426)
because more data is in flight during session teardown.

Add early-return guards for both cases to prevent the crash.

Refs: #38426
Refs: #56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 83b091065d] http2: guard against null stream/req in OnStreamAfterReqFinished
Author: Matteo Collina <hello@matteocollina.com>
Date: Thu Jul 23 14:28:24 2026 +0000
1 file changed, 2 insertions(+)
Rebasing (5/10)
Rebasing (6/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: relax framesReceived assertion in perf_hooks test

With the default window size increase, the server sends an additional
WINDOW_UPDATE frame during session setup, increasing the frames received
by the client from 7 to 8 on some platforms. Relax the assertion to
check >= 7 instead of strict equality.

Refs: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 4a7c271e8b] http2: relax framesReceived assertion in perf_hooks test
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 08:19:42 2026 +0000
1 file changed, 5 insertions(+), 1 deletion(-)
Rebasing (7/10)
Rebasing (8/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
stream: fix pending_writes underflow in StreamPipe shutdown

When the writable sink is destroyed while there are still pending
writes, WritableListener::OnStreamDestroy previously reset
pending_writes_ to 0. This caused OnStreamAfterWrite to decrement
the counter below 0, making the pending_writes_ == 0 completion
check fail permanently — the oncomplete callback was never called,
causing a timeout.

Fix by:

  1. Not resetting pending_writes_ in OnStreamDestroy — let
    OnStreamAfterWrite track completion naturally.
  2. Using sink_destroyed_ flag in Unpipe to always remove the
    writable listener regardless of pending_writes_ count.
  3. Using <= 0 (instead of == 0) when sink_destroyed_ is set,
    and guarding RemoveStreamListener against a null stream.

This race became more likely with larger HTTP/2 windows (#38426)
because more writes are in flight when session teardown begins.

Refs: #38426
Refs: #56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 9d0e7f3fd7] stream: fix pending_writes underflow in StreamPipe shutdown
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 11:03:27 2026 +0000
1 file changed, 13 insertions(+), 4 deletions(-)
Rebasing (9/10)
Rebasing (10/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
style: fix clang-format alignment in CHECK_EQ call

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 6cbbcc670b] style: fix clang-format alignment in CHECK_EQ call
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 15:10:46 2026 +0000
1 file changed, 3 insertions(+), 5 deletions(-)
Successfully rebased and updated refs/heads/main.

ℹ Add commit-queue-squash label to land the PR as one commit, or commit-queue-rebase to land as separate commits.

https://github.com/nodejs/node/actions/runs/30825144898

@trivikrtrivikr removed the commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. label Aug 3, 2026
@trivikr

Copy link
Copy Markdown
Member

@mcollina This either needs commit-queue-squash or commit-queue-rebase

@mcollinamcollina added commit-queue-squash PRs the Commit Queue should land as one squashed commit. commit-queue PRs queued for automated landing through the Commit Queue. labels Aug 3, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 3, 2026
@aduh95aduh95 added the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 4, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 4, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 1576cb8 into nodejs:mainAug 4, 2026
82 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 1576cb8

aduh95 pushed a commit that referenced this pull request Aug 13, 2026
Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).
The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.
Fixes: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Sign up for freeto 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++.commit-queue-squashPRs the Commit Queue should land as one squashed commit.lib / srcIssues and PRs involving general changes in the lib/ or src/ directories.semver-majorPRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase HTTP/2 window size by default

13 participants

@mcollina@nodejs-github-bot@pimterry@Ethan-Arrowood@trivikr@jasnell@ronag@metcoder95@RafaelGSS@avivkeller@gurgunday@bjohansebas@aduh95
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

http2: increase default window sizes - #64623

Merged
nodejs-github-bot merged 5 commits into
nodejs:mainfrom
mcollina:increase-http2-window-size
Aug 4, 2026
Merged

http2: increase default window sizes#64623
nodejs-github-bot merged 5 commits into
nodejs:mainfrom
mcollina:increase-http2-window-size

Conversation

@mcollina

Copy link
Copy Markdown
Member

Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).

The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.

Fixes#38426

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

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

@nodejs-github-botnodejs-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 Jul 20, 2026
@mcollina
mcollina requested review from pimterry, ronag and trivikr and removed request for pimterryJuly 20, 2026 12:33
Comment threadsrc/node_http2.cc Outdated
// to window_size / RTT. With a 32MB connection window, throughput is
// significantly improved. See https://github.com/nodejs/node/issues/38426
CHECK_EQ(nghttp2_session_set_local_window_size(
session, NGHTTP2_FLAG_NONE, 0, 33554432), 0);

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.

There's a pre-existing issue that this exposes: you can't configure this in advance. You can only control the connection window with session.setLocalWindowSize once you have a session, but at that point this initial WINDOW_UPDATE has already been sent, and shrinking the window isn't effective as shown in the tests here (it just blocks further updates, it can't reduce what's already been sent). The stream window is configurable in advance (it's a SETTINGS parameter) but this connection window isn't.

That already existed implicitly but it was kind of OK when the initial window was small, but it's a real problem with a very large initial window I think, since there's basically no way to override this to make it any smaller again if you need to.

Can we add client & server options for this, so it can be configured before the first WINDOW_UPDATE is sent somehow?

Comment threadsrc/node_http2.cc Outdated
// to window_size / RTT. With a 32MB connection window, throughput is
// significantly improved. See https://github.com/nodejs/node/issues/38426
CHECK_EQ(nghttp2_session_set_local_window_size(
session, NGHTTP2_FLAG_NONE, 0, 33554432), 0);

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.

Nit: would be nicer to extract this as a constant

@codecov

codecovBot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.55556% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.16%. Comparing base (c8e2a82) to head (f399373).
⚠️ Report is 90 commits behind head on main.

Files with missing linesPatch %Lines
src/stream_pipe.cc0.00%4 Missing and 1 partial ⚠️
src/stream_base.cc0.00%0 Missing and 2 partials ⚠️
src/node_http2.cc0.00%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #64623 +/- ##
==========================================
- Coverage 90.16% 90.16% -0.01% 
==========================================
Files 746 746 Lines 242760 242773 +13 Branches 45765 45766 +1 ==========================================
+ Hits 218875 218885 +10 + Misses 15375 15368 -7 - Partials 8510 8520 +10 
Files with missing linesCoverage Δ
lib/internal/http2/core.js95.07% <100.00%> (+0.01%)⬆️
src/node_http2.h92.26% <ø> (ø)
src/node_http2.cc81.66% <0.00%> (-0.09%)⬇️
src/stream_base.cc79.74% <0.00%> (-0.30%)⬇️
src/stream_pipe.cc56.48% <0.00%> (-3.06%)⬇️

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

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch 2 times, most recently from 5c9bc03 to 4351b51CompareJuly 20, 2026 16:48
@mcollina

Copy link
Copy Markdown
MemberAuthor

Both addressed:

  1. Extracted DEFAULT_SETTINGS_LOCAL_CONNECTION_WINDOW_SIZE = 33554432 as a named constant in src/node_http2.h and used it in src/node_http2.cc.
  2. The pre-existing issue about not being able to configure the connection window in advance is noted — the initial WINDOW_UPDATE is sent at session creation before setLocalWindowSize can be called. This is a known limitation of the current API.

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from 4351b51 to 31761a0CompareJuly 20, 2026 18:25

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

Wouldn't it be semver-majorPRs that contain breaking changes and should be released in the next major version. ?

@mcollinamcollina added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jul 20, 2026
@mcollina

Copy link
Copy Markdown
MemberAuthor

yes

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch 3 times, most recently from 70882db to bd4cbd3CompareJuly 21, 2026 16:44
@pimterry

Copy link
Copy Markdown
Member

The pre-existing issue about not being able to configure the connection window in advance is noted — the initial WINDOW_UPDATE is sent at session creation before setLocalWindowSize can be called. This is a known limitation of the current API.

I do think this would be useful, but doesn't need to block this - I'll open a separate PR.

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from bd4cbd3 to 86b969bCompareJuly 21, 2026 22:16
@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from 86b969b to d0c68baCompareJuly 22, 2026 09:39

@Ethan-ArrowoodEthan-Arrowood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CI failure seems related to the change here; test-http2-respond-with-file-connection-abort is failing across multiple systems and that isn't a known flake. Leaving a request changes to this gets fixed before landing.

When a stream is destroyed while a synchronous write is in flight
from StreamPipe::ProcessData, ReportWritesToJSStreamListener::
OnStreamAfterReqFinished can be called with a null stream_ or a
null req_wrap, causing a null pointer dereference. This race
becomes more likely with larger HTTP/2 windows (e.g., nodejs#38426)
because more data is in flight during session teardown.
Add early-return guards for both cases to prevent the crash.
Refs: nodejs#38426
Refs: nodejs#56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
With the default window size increase, the server sends an additional
WINDOW_UPDATE frame during session setup, increasing the frames received
by the client from 7 to 8 on some platforms. Relax the assertion to
check >= 7 instead of strict equality.
Refs: nodejs#38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
When the writable sink is destroyed while there are still pending
writes, WritableListener::OnStreamDestroy previously reset
pending_writes_ to 0. This caused OnStreamAfterWrite to decrement
the counter below 0, making the pending_writes_ == 0 completion
check fail permanently — the oncomplete callback was never called,
causing a timeout.
Fix by:
1. Not resetting pending_writes_ in OnStreamDestroy — let
OnStreamAfterWrite track completion naturally.
2. Using sink_destroyed_ flag in Unpipe to always remove the
writable listener regardless of pending_writes_ count.
3. Using <= 0 (instead of == 0) when sink_destroyed_ is set,
and guarding RemoveStreamListener against a null stream.
This race became more likely with larger HTTP/2 windows (nodejs#38426)
because more writes are in flight when session teardown begins.
Refs: nodejs#38426
Refs: nodejs#56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from a25a676 to f399373CompareJuly 30, 2026 21:20
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 2, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mcollinamcollina added commit-queue PRs queued for automated landing through the Commit Queue. and removed needs-ci PRs that need a full CI run. labels Aug 3, 2026
@nodejs-github-botnodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Aug 3, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/64623
✔ Done loading data for nodejs/node/pull/64623
----------------------------------- PR info ------------------------------------
Title http2: increase default window sizes (#64623)
Author Matteo Collina <matteo.collina@gmail.com> (@mcollina)
Branch mcollina:increase-http2-window-size -> nodejs:main
Labels c++, semver-major, lib / src
Commits 5
- http2: increase default window sizes
- http2: guard against null stream/req in OnStreamAfterReqFinished
- http2: relax framesReceived assertion in perf_hooks test
- stream: fix pending_writes underflow in StreamPipe shutdown
- style: fix clang-format alignment in CHECK_EQ call
Committers 1
- Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
--------------------------------------------------------------------------------
ℹ This PR was created on Mon, 20 Jul 2026 12:33:00 GMT
✔ Approvals: 8
✔ - Rafael Gonzaga (@RafaelGSS) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4737957628
✔ - Tim Perry (@pimterry): https://github.com/nodejs/node/pull/64623#pullrequestreview-4765202215
✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4749623762
✔ - Gürgün Dayıoğlu (@gurgunday): https://github.com/nodejs/node/pull/64623#pullrequestreview-4765616109
✔ - Ethan Arrowood (@Ethan-Arrowood): https://github.com/nodejs/node/pull/64623#pullrequestreview-4767534645
✔ - Aviv Keller (@avivkeller): https://github.com/nodejs/node/pull/64623#pullrequestreview-4770440465
✔ - Robert Nagy (@ronag) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4838488304
✔ - Trivikram Kamat (@trivikr): https://github.com/nodejs/node/pull/64623#pullrequestreview-4841424027
✔ Last GitHub CI successful
ℹ Last Full PR CI on 2026-08-03T12:22:08Z: https://ci.nodejs.org/job/node-test-pull-request/75428/
- Querying data for job/node-test-pull-request/75428/
✔ Build data downloaded
✔ Last Jenkins CI successful
--------------------------------------------------------------------------------
✔ No git cherry-pick in progress
✔ No git am in progress
✔ No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
* branch main -> FETCH_HEAD
✔ origin/main is now up-to-date
- Downloading patch for 64623
From https://github.com/nodejs/node
* branch refs/pull/64623/merge -> FETCH_HEAD
✔ Fetched commits as 7e439828de88..f3993733daf8
--------------------------------------------------------------------------------
Auto-merging doc/api/http2.md
[main d458cadee7] http2: increase default window sizes
Author: Matteo Collina <hello@matteocollina.com>
Date: Mon Jul 20 12:09:08 2026 +0000
16 files changed, 78 insertions(+), 61 deletions(-)
[main 2e28518bd9] http2: guard against null stream/req in OnStreamAfterReqFinished
Author: Matteo Collina <hello@matteocollina.com>
Date: Thu Jul 23 14:28:24 2026 +0000
1 file changed, 2 insertions(+)
[main 8974b46a94] http2: relax framesReceived assertion in perf_hooks test
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 08:19:42 2026 +0000
1 file changed, 5 insertions(+), 1 deletion(-)
[main 83d3ac6cb0] stream: fix pending_writes underflow in StreamPipe shutdown
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 11:03:27 2026 +0000
1 file changed, 13 insertions(+), 4 deletions(-)
[main 93ebe33adb] style: fix clang-format alignment in CHECK_EQ call
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 15:10:46 2026 +0000
1 file changed, 3 insertions(+), 5 deletions(-)
✔ Patches applied
There are 5 commits in the PR. Attempting autorebase.
(node:365) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Rebasing (2/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: increase default window sizes

Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).

The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.

Fixes: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 221808bb0e] http2: increase default window sizes
Author: Matteo Collina <hello@matteocollina.com>
Date: Mon Jul 20 12:09:08 2026 +0000
16 files changed, 78 insertions(+), 61 deletions(-)
Rebasing (3/10)
Rebasing (4/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: guard against null stream/req in OnStreamAfterReqFinished

When a stream is destroyed while a synchronous write is in flight
from StreamPipe::ProcessData, ReportWritesToJSStreamListener::
OnStreamAfterReqFinished can be called with a null stream_ or a
null req_wrap, causing a null pointer dereference. This race
becomes more likely with larger HTTP/2 windows (e.g., #38426)
because more data is in flight during session teardown.

Add early-return guards for both cases to prevent the crash.

Refs: #38426
Refs: #56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 83b091065d] http2: guard against null stream/req in OnStreamAfterReqFinished
Author: Matteo Collina <hello@matteocollina.com>
Date: Thu Jul 23 14:28:24 2026 +0000
1 file changed, 2 insertions(+)
Rebasing (5/10)
Rebasing (6/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: relax framesReceived assertion in perf_hooks test

With the default window size increase, the server sends an additional
WINDOW_UPDATE frame during session setup, increasing the frames received
by the client from 7 to 8 on some platforms. Relax the assertion to
check >= 7 instead of strict equality.

Refs: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 4a7c271e8b] http2: relax framesReceived assertion in perf_hooks test
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 08:19:42 2026 +0000
1 file changed, 5 insertions(+), 1 deletion(-)
Rebasing (7/10)
Rebasing (8/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
stream: fix pending_writes underflow in StreamPipe shutdown

When the writable sink is destroyed while there are still pending
writes, WritableListener::OnStreamDestroy previously reset
pending_writes_ to 0. This caused OnStreamAfterWrite to decrement
the counter below 0, making the pending_writes_ == 0 completion
check fail permanently — the oncomplete callback was never called,
causing a timeout.

Fix by:

  1. Not resetting pending_writes_ in OnStreamDestroy — let
    OnStreamAfterWrite track completion naturally.
  2. Using sink_destroyed_ flag in Unpipe to always remove the
    writable listener regardless of pending_writes_ count.
  3. Using <= 0 (instead of == 0) when sink_destroyed_ is set,
    and guarding RemoveStreamListener against a null stream.

This race became more likely with larger HTTP/2 windows (#38426)
because more writes are in flight when session teardown begins.

Refs: #38426
Refs: #56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 9d0e7f3fd7] stream: fix pending_writes underflow in StreamPipe shutdown
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 11:03:27 2026 +0000
1 file changed, 13 insertions(+), 4 deletions(-)
Rebasing (9/10)
Rebasing (10/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
style: fix clang-format alignment in CHECK_EQ call

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 6cbbcc670b] style: fix clang-format alignment in CHECK_EQ call
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 15:10:46 2026 +0000
1 file changed, 3 insertions(+), 5 deletions(-)
Successfully rebased and updated refs/heads/main.

ℹ Add commit-queue-squash label to land the PR as one commit, or commit-queue-rebase to land as separate commits.

https://github.com/nodejs/node/actions/runs/30825144898

@trivikrtrivikr removed the commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. label Aug 3, 2026
@trivikr

Copy link
Copy Markdown
Member

@mcollina This either needs commit-queue-squash or commit-queue-rebase

@mcollinamcollina added commit-queue-squash PRs the Commit Queue should land as one squashed commit. commit-queue PRs queued for automated landing through the Commit Queue. labels Aug 3, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 3, 2026
@aduh95aduh95 added the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 4, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 4, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 1576cb8 into nodejs:mainAug 4, 2026
82 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 1576cb8

aduh95 pushed a commit that referenced this pull request Aug 13, 2026
Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).
The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.
Fixes: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Sign up for freeto 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++.commit-queue-squashPRs the Commit Queue should land as one squashed commit.lib / srcIssues and PRs involving general changes in the lib/ or src/ directories.semver-majorPRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase HTTP/2 window size by default

13 participants

@mcollina@nodejs-github-bot@pimterry@Ethan-Arrowood@trivikr@jasnell@ronag@metcoder95@RafaelGSS@avivkeller@gurgunday@bjohansebas@aduh95
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

http2: increase default window sizes - #64623

Merged
nodejs-github-bot merged 5 commits into
nodejs:mainfrom
mcollina:increase-http2-window-size
Aug 4, 2026
Merged

http2: increase default window sizes#64623
nodejs-github-bot merged 5 commits into
nodejs:mainfrom
mcollina:increase-http2-window-size

Conversation

@mcollina

Copy link
Copy Markdown
Member

Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).

The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.

Fixes#38426

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

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

@nodejs-github-botnodejs-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 Jul 20, 2026
@mcollina
mcollina requested review from pimterry, ronag and trivikr and removed request for pimterryJuly 20, 2026 12:33
Comment threadsrc/node_http2.cc Outdated
// to window_size / RTT. With a 32MB connection window, throughput is
// significantly improved. See https://github.com/nodejs/node/issues/38426
CHECK_EQ(nghttp2_session_set_local_window_size(
session, NGHTTP2_FLAG_NONE, 0, 33554432), 0);

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.

There's a pre-existing issue that this exposes: you can't configure this in advance. You can only control the connection window with session.setLocalWindowSize once you have a session, but at that point this initial WINDOW_UPDATE has already been sent, and shrinking the window isn't effective as shown in the tests here (it just blocks further updates, it can't reduce what's already been sent). The stream window is configurable in advance (it's a SETTINGS parameter) but this connection window isn't.

That already existed implicitly but it was kind of OK when the initial window was small, but it's a real problem with a very large initial window I think, since there's basically no way to override this to make it any smaller again if you need to.

Can we add client & server options for this, so it can be configured before the first WINDOW_UPDATE is sent somehow?

Comment threadsrc/node_http2.cc Outdated
// to window_size / RTT. With a 32MB connection window, throughput is
// significantly improved. See https://github.com/nodejs/node/issues/38426
CHECK_EQ(nghttp2_session_set_local_window_size(
session, NGHTTP2_FLAG_NONE, 0, 33554432), 0);

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.

Nit: would be nicer to extract this as a constant

@codecov

codecovBot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.55556% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.16%. Comparing base (c8e2a82) to head (f399373).
⚠️ Report is 90 commits behind head on main.

Files with missing linesPatch %Lines
src/stream_pipe.cc0.00%4 Missing and 1 partial ⚠️
src/stream_base.cc0.00%0 Missing and 2 partials ⚠️
src/node_http2.cc0.00%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #64623 +/- ##
==========================================
- Coverage 90.16% 90.16% -0.01% 
==========================================
Files 746 746 Lines 242760 242773 +13 Branches 45765 45766 +1 ==========================================
+ Hits 218875 218885 +10 + Misses 15375 15368 -7 - Partials 8510 8520 +10 
Files with missing linesCoverage Δ
lib/internal/http2/core.js95.07% <100.00%> (+0.01%)⬆️
src/node_http2.h92.26% <ø> (ø)
src/node_http2.cc81.66% <0.00%> (-0.09%)⬇️
src/stream_base.cc79.74% <0.00%> (-0.30%)⬇️
src/stream_pipe.cc56.48% <0.00%> (-3.06%)⬇️

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

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch 2 times, most recently from 5c9bc03 to 4351b51CompareJuly 20, 2026 16:48
@mcollina

Copy link
Copy Markdown
MemberAuthor

Both addressed:

  1. Extracted DEFAULT_SETTINGS_LOCAL_CONNECTION_WINDOW_SIZE = 33554432 as a named constant in src/node_http2.h and used it in src/node_http2.cc.
  2. The pre-existing issue about not being able to configure the connection window in advance is noted — the initial WINDOW_UPDATE is sent at session creation before setLocalWindowSize can be called. This is a known limitation of the current API.

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from 4351b51 to 31761a0CompareJuly 20, 2026 18:25

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

Wouldn't it be semver-majorPRs that contain breaking changes and should be released in the next major version. ?

@mcollinamcollina added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jul 20, 2026
@mcollina

Copy link
Copy Markdown
MemberAuthor

yes

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch 3 times, most recently from 70882db to bd4cbd3CompareJuly 21, 2026 16:44
@pimterry

Copy link
Copy Markdown
Member

The pre-existing issue about not being able to configure the connection window in advance is noted — the initial WINDOW_UPDATE is sent at session creation before setLocalWindowSize can be called. This is a known limitation of the current API.

I do think this would be useful, but doesn't need to block this - I'll open a separate PR.

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from bd4cbd3 to 86b969bCompareJuly 21, 2026 22:16
@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from 86b969b to d0c68baCompareJuly 22, 2026 09:39

@Ethan-ArrowoodEthan-Arrowood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CI failure seems related to the change here; test-http2-respond-with-file-connection-abort is failing across multiple systems and that isn't a known flake. Leaving a request changes to this gets fixed before landing.

When a stream is destroyed while a synchronous write is in flight
from StreamPipe::ProcessData, ReportWritesToJSStreamListener::
OnStreamAfterReqFinished can be called with a null stream_ or a
null req_wrap, causing a null pointer dereference. This race
becomes more likely with larger HTTP/2 windows (e.g., nodejs#38426)
because more data is in flight during session teardown.
Add early-return guards for both cases to prevent the crash.
Refs: nodejs#38426
Refs: nodejs#56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
With the default window size increase, the server sends an additional
WINDOW_UPDATE frame during session setup, increasing the frames received
by the client from 7 to 8 on some platforms. Relax the assertion to
check >= 7 instead of strict equality.
Refs: nodejs#38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
When the writable sink is destroyed while there are still pending
writes, WritableListener::OnStreamDestroy previously reset
pending_writes_ to 0. This caused OnStreamAfterWrite to decrement
the counter below 0, making the pending_writes_ == 0 completion
check fail permanently — the oncomplete callback was never called,
causing a timeout.
Fix by:
1. Not resetting pending_writes_ in OnStreamDestroy — let
OnStreamAfterWrite track completion naturally.
2. Using sink_destroyed_ flag in Unpipe to always remove the
writable listener regardless of pending_writes_ count.
3. Using <= 0 (instead of == 0) when sink_destroyed_ is set,
and guarding RemoveStreamListener against a null stream.
This race became more likely with larger HTTP/2 windows (nodejs#38426)
because more writes are in flight when session teardown begins.
Refs: nodejs#38426
Refs: nodejs#56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from a25a676 to f399373CompareJuly 30, 2026 21:20
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 2, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mcollinamcollina added commit-queue PRs queued for automated landing through the Commit Queue. and removed needs-ci PRs that need a full CI run. labels Aug 3, 2026
@nodejs-github-botnodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Aug 3, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/64623
✔ Done loading data for nodejs/node/pull/64623
----------------------------------- PR info ------------------------------------
Title http2: increase default window sizes (#64623)
Author Matteo Collina <matteo.collina@gmail.com> (@mcollina)
Branch mcollina:increase-http2-window-size -> nodejs:main
Labels c++, semver-major, lib / src
Commits 5
- http2: increase default window sizes
- http2: guard against null stream/req in OnStreamAfterReqFinished
- http2: relax framesReceived assertion in perf_hooks test
- stream: fix pending_writes underflow in StreamPipe shutdown
- style: fix clang-format alignment in CHECK_EQ call
Committers 1
- Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
--------------------------------------------------------------------------------
ℹ This PR was created on Mon, 20 Jul 2026 12:33:00 GMT
✔ Approvals: 8
✔ - Rafael Gonzaga (@RafaelGSS) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4737957628
✔ - Tim Perry (@pimterry): https://github.com/nodejs/node/pull/64623#pullrequestreview-4765202215
✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4749623762
✔ - Gürgün Dayıoğlu (@gurgunday): https://github.com/nodejs/node/pull/64623#pullrequestreview-4765616109
✔ - Ethan Arrowood (@Ethan-Arrowood): https://github.com/nodejs/node/pull/64623#pullrequestreview-4767534645
✔ - Aviv Keller (@avivkeller): https://github.com/nodejs/node/pull/64623#pullrequestreview-4770440465
✔ - Robert Nagy (@ronag) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4838488304
✔ - Trivikram Kamat (@trivikr): https://github.com/nodejs/node/pull/64623#pullrequestreview-4841424027
✔ Last GitHub CI successful
ℹ Last Full PR CI on 2026-08-03T12:22:08Z: https://ci.nodejs.org/job/node-test-pull-request/75428/
- Querying data for job/node-test-pull-request/75428/
✔ Build data downloaded
✔ Last Jenkins CI successful
--------------------------------------------------------------------------------
✔ No git cherry-pick in progress
✔ No git am in progress
✔ No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
* branch main -> FETCH_HEAD
✔ origin/main is now up-to-date
- Downloading patch for 64623
From https://github.com/nodejs/node
* branch refs/pull/64623/merge -> FETCH_HEAD
✔ Fetched commits as 7e439828de88..f3993733daf8
--------------------------------------------------------------------------------
Auto-merging doc/api/http2.md
[main d458cadee7] http2: increase default window sizes
Author: Matteo Collina <hello@matteocollina.com>
Date: Mon Jul 20 12:09:08 2026 +0000
16 files changed, 78 insertions(+), 61 deletions(-)
[main 2e28518bd9] http2: guard against null stream/req in OnStreamAfterReqFinished
Author: Matteo Collina <hello@matteocollina.com>
Date: Thu Jul 23 14:28:24 2026 +0000
1 file changed, 2 insertions(+)
[main 8974b46a94] http2: relax framesReceived assertion in perf_hooks test
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 08:19:42 2026 +0000
1 file changed, 5 insertions(+), 1 deletion(-)
[main 83d3ac6cb0] stream: fix pending_writes underflow in StreamPipe shutdown
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 11:03:27 2026 +0000
1 file changed, 13 insertions(+), 4 deletions(-)
[main 93ebe33adb] style: fix clang-format alignment in CHECK_EQ call
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 15:10:46 2026 +0000
1 file changed, 3 insertions(+), 5 deletions(-)
✔ Patches applied
There are 5 commits in the PR. Attempting autorebase.
(node:365) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Rebasing (2/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: increase default window sizes

Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).

The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.

Fixes: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 221808bb0e] http2: increase default window sizes
Author: Matteo Collina <hello@matteocollina.com>
Date: Mon Jul 20 12:09:08 2026 +0000
16 files changed, 78 insertions(+), 61 deletions(-)
Rebasing (3/10)
Rebasing (4/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: guard against null stream/req in OnStreamAfterReqFinished

When a stream is destroyed while a synchronous write is in flight
from StreamPipe::ProcessData, ReportWritesToJSStreamListener::
OnStreamAfterReqFinished can be called with a null stream_ or a
null req_wrap, causing a null pointer dereference. This race
becomes more likely with larger HTTP/2 windows (e.g., #38426)
because more data is in flight during session teardown.

Add early-return guards for both cases to prevent the crash.

Refs: #38426
Refs: #56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 83b091065d] http2: guard against null stream/req in OnStreamAfterReqFinished
Author: Matteo Collina <hello@matteocollina.com>
Date: Thu Jul 23 14:28:24 2026 +0000
1 file changed, 2 insertions(+)
Rebasing (5/10)
Rebasing (6/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: relax framesReceived assertion in perf_hooks test

With the default window size increase, the server sends an additional
WINDOW_UPDATE frame during session setup, increasing the frames received
by the client from 7 to 8 on some platforms. Relax the assertion to
check >= 7 instead of strict equality.

Refs: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 4a7c271e8b] http2: relax framesReceived assertion in perf_hooks test
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 08:19:42 2026 +0000
1 file changed, 5 insertions(+), 1 deletion(-)
Rebasing (7/10)
Rebasing (8/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
stream: fix pending_writes underflow in StreamPipe shutdown

When the writable sink is destroyed while there are still pending
writes, WritableListener::OnStreamDestroy previously reset
pending_writes_ to 0. This caused OnStreamAfterWrite to decrement
the counter below 0, making the pending_writes_ == 0 completion
check fail permanently — the oncomplete callback was never called,
causing a timeout.

Fix by:

  1. Not resetting pending_writes_ in OnStreamDestroy — let
    OnStreamAfterWrite track completion naturally.
  2. Using sink_destroyed_ flag in Unpipe to always remove the
    writable listener regardless of pending_writes_ count.
  3. Using <= 0 (instead of == 0) when sink_destroyed_ is set,
    and guarding RemoveStreamListener against a null stream.

This race became more likely with larger HTTP/2 windows (#38426)
because more writes are in flight when session teardown begins.

Refs: #38426
Refs: #56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 9d0e7f3fd7] stream: fix pending_writes underflow in StreamPipe shutdown
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 11:03:27 2026 +0000
1 file changed, 13 insertions(+), 4 deletions(-)
Rebasing (9/10)
Rebasing (10/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
style: fix clang-format alignment in CHECK_EQ call

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 6cbbcc670b] style: fix clang-format alignment in CHECK_EQ call
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 15:10:46 2026 +0000
1 file changed, 3 insertions(+), 5 deletions(-)
Successfully rebased and updated refs/heads/main.

ℹ Add commit-queue-squash label to land the PR as one commit, or commit-queue-rebase to land as separate commits.

https://github.com/nodejs/node/actions/runs/30825144898

@trivikrtrivikr removed the commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. label Aug 3, 2026
@trivikr

Copy link
Copy Markdown
Member

@mcollina This either needs commit-queue-squash or commit-queue-rebase

@mcollinamcollina added commit-queue-squash PRs the Commit Queue should land as one squashed commit. commit-queue PRs queued for automated landing through the Commit Queue. labels Aug 3, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 3, 2026
@aduh95aduh95 added the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 4, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 4, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 1576cb8 into nodejs:mainAug 4, 2026
82 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 1576cb8

aduh95 pushed a commit that referenced this pull request Aug 13, 2026
Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).
The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.
Fixes: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Sign up for freeto 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++.commit-queue-squashPRs the Commit Queue should land as one squashed commit.lib / srcIssues and PRs involving general changes in the lib/ or src/ directories.semver-majorPRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase HTTP/2 window size by default

13 participants

@mcollina@nodejs-github-bot@pimterry@Ethan-Arrowood@trivikr@jasnell@ronag@metcoder95@RafaelGSS@avivkeller@gurgunday@bjohansebas@aduh95
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

http2: increase default window sizes - #64623

Merged
nodejs-github-bot merged 5 commits into
nodejs:mainfrom
mcollina:increase-http2-window-size
Aug 4, 2026
Merged

http2: increase default window sizes#64623
nodejs-github-bot merged 5 commits into
nodejs:mainfrom
mcollina:increase-http2-window-size

Conversation

@mcollina

Copy link
Copy Markdown
Member

Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).

The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.

Fixes#38426

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

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

@nodejs-github-botnodejs-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 Jul 20, 2026
@mcollina
mcollina requested review from pimterry, ronag and trivikr and removed request for pimterryJuly 20, 2026 12:33
Comment threadsrc/node_http2.cc Outdated
// to window_size / RTT. With a 32MB connection window, throughput is
// significantly improved. See https://github.com/nodejs/node/issues/38426
CHECK_EQ(nghttp2_session_set_local_window_size(
session, NGHTTP2_FLAG_NONE, 0, 33554432), 0);

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.

There's a pre-existing issue that this exposes: you can't configure this in advance. You can only control the connection window with session.setLocalWindowSize once you have a session, but at that point this initial WINDOW_UPDATE has already been sent, and shrinking the window isn't effective as shown in the tests here (it just blocks further updates, it can't reduce what's already been sent). The stream window is configurable in advance (it's a SETTINGS parameter) but this connection window isn't.

That already existed implicitly but it was kind of OK when the initial window was small, but it's a real problem with a very large initial window I think, since there's basically no way to override this to make it any smaller again if you need to.

Can we add client & server options for this, so it can be configured before the first WINDOW_UPDATE is sent somehow?

Comment threadsrc/node_http2.cc Outdated
// to window_size / RTT. With a 32MB connection window, throughput is
// significantly improved. See https://github.com/nodejs/node/issues/38426
CHECK_EQ(nghttp2_session_set_local_window_size(
session, NGHTTP2_FLAG_NONE, 0, 33554432), 0);

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.

Nit: would be nicer to extract this as a constant

@codecov

codecovBot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.55556% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.16%. Comparing base (c8e2a82) to head (f399373).
⚠️ Report is 90 commits behind head on main.

Files with missing linesPatch %Lines
src/stream_pipe.cc0.00%4 Missing and 1 partial ⚠️
src/stream_base.cc0.00%0 Missing and 2 partials ⚠️
src/node_http2.cc0.00%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #64623 +/- ##
==========================================
- Coverage 90.16% 90.16% -0.01% 
==========================================
Files 746 746 Lines 242760 242773 +13 Branches 45765 45766 +1 ==========================================
+ Hits 218875 218885 +10 + Misses 15375 15368 -7 - Partials 8510 8520 +10 
Files with missing linesCoverage Δ
lib/internal/http2/core.js95.07% <100.00%> (+0.01%)⬆️
src/node_http2.h92.26% <ø> (ø)
src/node_http2.cc81.66% <0.00%> (-0.09%)⬇️
src/stream_base.cc79.74% <0.00%> (-0.30%)⬇️
src/stream_pipe.cc56.48% <0.00%> (-3.06%)⬇️

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

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch 2 times, most recently from 5c9bc03 to 4351b51CompareJuly 20, 2026 16:48
@mcollina

Copy link
Copy Markdown
MemberAuthor

Both addressed:

  1. Extracted DEFAULT_SETTINGS_LOCAL_CONNECTION_WINDOW_SIZE = 33554432 as a named constant in src/node_http2.h and used it in src/node_http2.cc.
  2. The pre-existing issue about not being able to configure the connection window in advance is noted — the initial WINDOW_UPDATE is sent at session creation before setLocalWindowSize can be called. This is a known limitation of the current API.

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from 4351b51 to 31761a0CompareJuly 20, 2026 18:25

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

Wouldn't it be semver-majorPRs that contain breaking changes and should be released in the next major version. ?

@mcollinamcollina added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jul 20, 2026
@mcollina

Copy link
Copy Markdown
MemberAuthor

yes

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch 3 times, most recently from 70882db to bd4cbd3CompareJuly 21, 2026 16:44
@pimterry

Copy link
Copy Markdown
Member

The pre-existing issue about not being able to configure the connection window in advance is noted — the initial WINDOW_UPDATE is sent at session creation before setLocalWindowSize can be called. This is a known limitation of the current API.

I do think this would be useful, but doesn't need to block this - I'll open a separate PR.

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from bd4cbd3 to 86b969bCompareJuly 21, 2026 22:16
@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from 86b969b to d0c68baCompareJuly 22, 2026 09:39

@Ethan-ArrowoodEthan-Arrowood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CI failure seems related to the change here; test-http2-respond-with-file-connection-abort is failing across multiple systems and that isn't a known flake. Leaving a request changes to this gets fixed before landing.

When a stream is destroyed while a synchronous write is in flight
from StreamPipe::ProcessData, ReportWritesToJSStreamListener::
OnStreamAfterReqFinished can be called with a null stream_ or a
null req_wrap, causing a null pointer dereference. This race
becomes more likely with larger HTTP/2 windows (e.g., nodejs#38426)
because more data is in flight during session teardown.
Add early-return guards for both cases to prevent the crash.
Refs: nodejs#38426
Refs: nodejs#56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
With the default window size increase, the server sends an additional
WINDOW_UPDATE frame during session setup, increasing the frames received
by the client from 7 to 8 on some platforms. Relax the assertion to
check >= 7 instead of strict equality.
Refs: nodejs#38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
When the writable sink is destroyed while there are still pending
writes, WritableListener::OnStreamDestroy previously reset
pending_writes_ to 0. This caused OnStreamAfterWrite to decrement
the counter below 0, making the pending_writes_ == 0 completion
check fail permanently — the oncomplete callback was never called,
causing a timeout.
Fix by:
1. Not resetting pending_writes_ in OnStreamDestroy — let
OnStreamAfterWrite track completion naturally.
2. Using sink_destroyed_ flag in Unpipe to always remove the
writable listener regardless of pending_writes_ count.
3. Using <= 0 (instead of == 0) when sink_destroyed_ is set,
and guarding RemoveStreamListener against a null stream.
This race became more likely with larger HTTP/2 windows (nodejs#38426)
because more writes are in flight when session teardown begins.
Refs: nodejs#38426
Refs: nodejs#56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from a25a676 to f399373CompareJuly 30, 2026 21:20
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 2, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mcollinamcollina added commit-queue PRs queued for automated landing through the Commit Queue. and removed needs-ci PRs that need a full CI run. labels Aug 3, 2026
@nodejs-github-botnodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Aug 3, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/64623
✔ Done loading data for nodejs/node/pull/64623
----------------------------------- PR info ------------------------------------
Title http2: increase default window sizes (#64623)
Author Matteo Collina <matteo.collina@gmail.com> (@mcollina)
Branch mcollina:increase-http2-window-size -> nodejs:main
Labels c++, semver-major, lib / src
Commits 5
- http2: increase default window sizes
- http2: guard against null stream/req in OnStreamAfterReqFinished
- http2: relax framesReceived assertion in perf_hooks test
- stream: fix pending_writes underflow in StreamPipe shutdown
- style: fix clang-format alignment in CHECK_EQ call
Committers 1
- Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
--------------------------------------------------------------------------------
ℹ This PR was created on Mon, 20 Jul 2026 12:33:00 GMT
✔ Approvals: 8
✔ - Rafael Gonzaga (@RafaelGSS) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4737957628
✔ - Tim Perry (@pimterry): https://github.com/nodejs/node/pull/64623#pullrequestreview-4765202215
✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4749623762
✔ - Gürgün Dayıoğlu (@gurgunday): https://github.com/nodejs/node/pull/64623#pullrequestreview-4765616109
✔ - Ethan Arrowood (@Ethan-Arrowood): https://github.com/nodejs/node/pull/64623#pullrequestreview-4767534645
✔ - Aviv Keller (@avivkeller): https://github.com/nodejs/node/pull/64623#pullrequestreview-4770440465
✔ - Robert Nagy (@ronag) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4838488304
✔ - Trivikram Kamat (@trivikr): https://github.com/nodejs/node/pull/64623#pullrequestreview-4841424027
✔ Last GitHub CI successful
ℹ Last Full PR CI on 2026-08-03T12:22:08Z: https://ci.nodejs.org/job/node-test-pull-request/75428/
- Querying data for job/node-test-pull-request/75428/
✔ Build data downloaded
✔ Last Jenkins CI successful
--------------------------------------------------------------------------------
✔ No git cherry-pick in progress
✔ No git am in progress
✔ No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
* branch main -> FETCH_HEAD
✔ origin/main is now up-to-date
- Downloading patch for 64623
From https://github.com/nodejs/node
* branch refs/pull/64623/merge -> FETCH_HEAD
✔ Fetched commits as 7e439828de88..f3993733daf8
--------------------------------------------------------------------------------
Auto-merging doc/api/http2.md
[main d458cadee7] http2: increase default window sizes
Author: Matteo Collina <hello@matteocollina.com>
Date: Mon Jul 20 12:09:08 2026 +0000
16 files changed, 78 insertions(+), 61 deletions(-)
[main 2e28518bd9] http2: guard against null stream/req in OnStreamAfterReqFinished
Author: Matteo Collina <hello@matteocollina.com>
Date: Thu Jul 23 14:28:24 2026 +0000
1 file changed, 2 insertions(+)
[main 8974b46a94] http2: relax framesReceived assertion in perf_hooks test
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 08:19:42 2026 +0000
1 file changed, 5 insertions(+), 1 deletion(-)
[main 83d3ac6cb0] stream: fix pending_writes underflow in StreamPipe shutdown
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 11:03:27 2026 +0000
1 file changed, 13 insertions(+), 4 deletions(-)
[main 93ebe33adb] style: fix clang-format alignment in CHECK_EQ call
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 15:10:46 2026 +0000
1 file changed, 3 insertions(+), 5 deletions(-)
✔ Patches applied
There are 5 commits in the PR. Attempting autorebase.
(node:365) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Rebasing (2/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: increase default window sizes

Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).

The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.

Fixes: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 221808bb0e] http2: increase default window sizes
Author: Matteo Collina <hello@matteocollina.com>
Date: Mon Jul 20 12:09:08 2026 +0000
16 files changed, 78 insertions(+), 61 deletions(-)
Rebasing (3/10)
Rebasing (4/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: guard against null stream/req in OnStreamAfterReqFinished

When a stream is destroyed while a synchronous write is in flight
from StreamPipe::ProcessData, ReportWritesToJSStreamListener::
OnStreamAfterReqFinished can be called with a null stream_ or a
null req_wrap, causing a null pointer dereference. This race
becomes more likely with larger HTTP/2 windows (e.g., #38426)
because more data is in flight during session teardown.

Add early-return guards for both cases to prevent the crash.

Refs: #38426
Refs: #56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 83b091065d] http2: guard against null stream/req in OnStreamAfterReqFinished
Author: Matteo Collina <hello@matteocollina.com>
Date: Thu Jul 23 14:28:24 2026 +0000
1 file changed, 2 insertions(+)
Rebasing (5/10)
Rebasing (6/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: relax framesReceived assertion in perf_hooks test

With the default window size increase, the server sends an additional
WINDOW_UPDATE frame during session setup, increasing the frames received
by the client from 7 to 8 on some platforms. Relax the assertion to
check >= 7 instead of strict equality.

Refs: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 4a7c271e8b] http2: relax framesReceived assertion in perf_hooks test
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 08:19:42 2026 +0000
1 file changed, 5 insertions(+), 1 deletion(-)
Rebasing (7/10)
Rebasing (8/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
stream: fix pending_writes underflow in StreamPipe shutdown

When the writable sink is destroyed while there are still pending
writes, WritableListener::OnStreamDestroy previously reset
pending_writes_ to 0. This caused OnStreamAfterWrite to decrement
the counter below 0, making the pending_writes_ == 0 completion
check fail permanently — the oncomplete callback was never called,
causing a timeout.

Fix by:

  1. Not resetting pending_writes_ in OnStreamDestroy — let
    OnStreamAfterWrite track completion naturally.
  2. Using sink_destroyed_ flag in Unpipe to always remove the
    writable listener regardless of pending_writes_ count.
  3. Using <= 0 (instead of == 0) when sink_destroyed_ is set,
    and guarding RemoveStreamListener against a null stream.

This race became more likely with larger HTTP/2 windows (#38426)
because more writes are in flight when session teardown begins.

Refs: #38426
Refs: #56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 9d0e7f3fd7] stream: fix pending_writes underflow in StreamPipe shutdown
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 11:03:27 2026 +0000
1 file changed, 13 insertions(+), 4 deletions(-)
Rebasing (9/10)
Rebasing (10/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
style: fix clang-format alignment in CHECK_EQ call

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 6cbbcc670b] style: fix clang-format alignment in CHECK_EQ call
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 15:10:46 2026 +0000
1 file changed, 3 insertions(+), 5 deletions(-)
Successfully rebased and updated refs/heads/main.

ℹ Add commit-queue-squash label to land the PR as one commit, or commit-queue-rebase to land as separate commits.

https://github.com/nodejs/node/actions/runs/30825144898

@trivikrtrivikr removed the commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. label Aug 3, 2026
@trivikr

Copy link
Copy Markdown
Member

@mcollina This either needs commit-queue-squash or commit-queue-rebase

@mcollinamcollina added commit-queue-squash PRs the Commit Queue should land as one squashed commit. commit-queue PRs queued for automated landing through the Commit Queue. labels Aug 3, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 3, 2026
@aduh95aduh95 added the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 4, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 4, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 1576cb8 into nodejs:mainAug 4, 2026
82 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 1576cb8

aduh95 pushed a commit that referenced this pull request Aug 13, 2026
Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).
The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.
Fixes: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Sign up for freeto 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++.commit-queue-squashPRs the Commit Queue should land as one squashed commit.lib / srcIssues and PRs involving general changes in the lib/ or src/ directories.semver-majorPRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase HTTP/2 window size by default

13 participants

@mcollina@nodejs-github-bot@pimterry@Ethan-Arrowood@trivikr@jasnell@ronag@metcoder95@RafaelGSS@avivkeller@gurgunday@bjohansebas@aduh95
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

http2: increase default window sizes - #64623

Merged
nodejs-github-bot merged 5 commits into
nodejs:mainfrom
mcollina:increase-http2-window-size
Aug 4, 2026
Merged

http2: increase default window sizes#64623
nodejs-github-bot merged 5 commits into
nodejs:mainfrom
mcollina:increase-http2-window-size

Conversation

@mcollina

Copy link
Copy Markdown
Member

Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).

The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.

Fixes#38426

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

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

@nodejs-github-botnodejs-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 Jul 20, 2026
@mcollina
mcollina requested review from pimterry, ronag and trivikr and removed request for pimterryJuly 20, 2026 12:33
Comment threadsrc/node_http2.cc Outdated
// to window_size / RTT. With a 32MB connection window, throughput is
// significantly improved. See https://github.com/nodejs/node/issues/38426
CHECK_EQ(nghttp2_session_set_local_window_size(
session, NGHTTP2_FLAG_NONE, 0, 33554432), 0);

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.

There's a pre-existing issue that this exposes: you can't configure this in advance. You can only control the connection window with session.setLocalWindowSize once you have a session, but at that point this initial WINDOW_UPDATE has already been sent, and shrinking the window isn't effective as shown in the tests here (it just blocks further updates, it can't reduce what's already been sent). The stream window is configurable in advance (it's a SETTINGS parameter) but this connection window isn't.

That already existed implicitly but it was kind of OK when the initial window was small, but it's a real problem with a very large initial window I think, since there's basically no way to override this to make it any smaller again if you need to.

Can we add client & server options for this, so it can be configured before the first WINDOW_UPDATE is sent somehow?

Comment threadsrc/node_http2.cc Outdated
// to window_size / RTT. With a 32MB connection window, throughput is
// significantly improved. See https://github.com/nodejs/node/issues/38426
CHECK_EQ(nghttp2_session_set_local_window_size(
session, NGHTTP2_FLAG_NONE, 0, 33554432), 0);

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.

Nit: would be nicer to extract this as a constant

@codecov

codecovBot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.55556% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.16%. Comparing base (c8e2a82) to head (f399373).
⚠️ Report is 90 commits behind head on main.

Files with missing linesPatch %Lines
src/stream_pipe.cc0.00%4 Missing and 1 partial ⚠️
src/stream_base.cc0.00%0 Missing and 2 partials ⚠️
src/node_http2.cc0.00%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #64623 +/- ##
==========================================
- Coverage 90.16% 90.16% -0.01% 
==========================================
Files 746 746 Lines 242760 242773 +13 Branches 45765 45766 +1 ==========================================
+ Hits 218875 218885 +10 + Misses 15375 15368 -7 - Partials 8510 8520 +10 
Files with missing linesCoverage Δ
lib/internal/http2/core.js95.07% <100.00%> (+0.01%)⬆️
src/node_http2.h92.26% <ø> (ø)
src/node_http2.cc81.66% <0.00%> (-0.09%)⬇️
src/stream_base.cc79.74% <0.00%> (-0.30%)⬇️
src/stream_pipe.cc56.48% <0.00%> (-3.06%)⬇️

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

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch 2 times, most recently from 5c9bc03 to 4351b51CompareJuly 20, 2026 16:48
@mcollina

Copy link
Copy Markdown
MemberAuthor

Both addressed:

  1. Extracted DEFAULT_SETTINGS_LOCAL_CONNECTION_WINDOW_SIZE = 33554432 as a named constant in src/node_http2.h and used it in src/node_http2.cc.
  2. The pre-existing issue about not being able to configure the connection window in advance is noted — the initial WINDOW_UPDATE is sent at session creation before setLocalWindowSize can be called. This is a known limitation of the current API.

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from 4351b51 to 31761a0CompareJuly 20, 2026 18:25

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

Wouldn't it be semver-majorPRs that contain breaking changes and should be released in the next major version. ?

@mcollinamcollina added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jul 20, 2026
@mcollina

Copy link
Copy Markdown
MemberAuthor

yes

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch 3 times, most recently from 70882db to bd4cbd3CompareJuly 21, 2026 16:44
@pimterry

Copy link
Copy Markdown
Member

The pre-existing issue about not being able to configure the connection window in advance is noted — the initial WINDOW_UPDATE is sent at session creation before setLocalWindowSize can be called. This is a known limitation of the current API.

I do think this would be useful, but doesn't need to block this - I'll open a separate PR.

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from bd4cbd3 to 86b969bCompareJuly 21, 2026 22:16
@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from 86b969b to d0c68baCompareJuly 22, 2026 09:39

@Ethan-ArrowoodEthan-Arrowood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CI failure seems related to the change here; test-http2-respond-with-file-connection-abort is failing across multiple systems and that isn't a known flake. Leaving a request changes to this gets fixed before landing.

When a stream is destroyed while a synchronous write is in flight
from StreamPipe::ProcessData, ReportWritesToJSStreamListener::
OnStreamAfterReqFinished can be called with a null stream_ or a
null req_wrap, causing a null pointer dereference. This race
becomes more likely with larger HTTP/2 windows (e.g., nodejs#38426)
because more data is in flight during session teardown.
Add early-return guards for both cases to prevent the crash.
Refs: nodejs#38426
Refs: nodejs#56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
With the default window size increase, the server sends an additional
WINDOW_UPDATE frame during session setup, increasing the frames received
by the client from 7 to 8 on some platforms. Relax the assertion to
check >= 7 instead of strict equality.
Refs: nodejs#38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
When the writable sink is destroyed while there are still pending
writes, WritableListener::OnStreamDestroy previously reset
pending_writes_ to 0. This caused OnStreamAfterWrite to decrement
the counter below 0, making the pending_writes_ == 0 completion
check fail permanently — the oncomplete callback was never called,
causing a timeout.
Fix by:
1. Not resetting pending_writes_ in OnStreamDestroy — let
OnStreamAfterWrite track completion naturally.
2. Using sink_destroyed_ flag in Unpipe to always remove the
writable listener regardless of pending_writes_ count.
3. Using <= 0 (instead of == 0) when sink_destroyed_ is set,
and guarding RemoveStreamListener against a null stream.
This race became more likely with larger HTTP/2 windows (nodejs#38426)
because more writes are in flight when session teardown begins.
Refs: nodejs#38426
Refs: nodejs#56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from a25a676 to f399373CompareJuly 30, 2026 21:20
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 2, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mcollinamcollina added commit-queue PRs queued for automated landing through the Commit Queue. and removed needs-ci PRs that need a full CI run. labels Aug 3, 2026
@nodejs-github-botnodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Aug 3, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/64623
✔ Done loading data for nodejs/node/pull/64623
----------------------------------- PR info ------------------------------------
Title http2: increase default window sizes (#64623)
Author Matteo Collina <matteo.collina@gmail.com> (@mcollina)
Branch mcollina:increase-http2-window-size -> nodejs:main
Labels c++, semver-major, lib / src
Commits 5
- http2: increase default window sizes
- http2: guard against null stream/req in OnStreamAfterReqFinished
- http2: relax framesReceived assertion in perf_hooks test
- stream: fix pending_writes underflow in StreamPipe shutdown
- style: fix clang-format alignment in CHECK_EQ call
Committers 1
- Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
--------------------------------------------------------------------------------
ℹ This PR was created on Mon, 20 Jul 2026 12:33:00 GMT
✔ Approvals: 8
✔ - Rafael Gonzaga (@RafaelGSS) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4737957628
✔ - Tim Perry (@pimterry): https://github.com/nodejs/node/pull/64623#pullrequestreview-4765202215
✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4749623762
✔ - Gürgün Dayıoğlu (@gurgunday): https://github.com/nodejs/node/pull/64623#pullrequestreview-4765616109
✔ - Ethan Arrowood (@Ethan-Arrowood): https://github.com/nodejs/node/pull/64623#pullrequestreview-4767534645
✔ - Aviv Keller (@avivkeller): https://github.com/nodejs/node/pull/64623#pullrequestreview-4770440465
✔ - Robert Nagy (@ronag) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4838488304
✔ - Trivikram Kamat (@trivikr): https://github.com/nodejs/node/pull/64623#pullrequestreview-4841424027
✔ Last GitHub CI successful
ℹ Last Full PR CI on 2026-08-03T12:22:08Z: https://ci.nodejs.org/job/node-test-pull-request/75428/
- Querying data for job/node-test-pull-request/75428/
✔ Build data downloaded
✔ Last Jenkins CI successful
--------------------------------------------------------------------------------
✔ No git cherry-pick in progress
✔ No git am in progress
✔ No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
* branch main -> FETCH_HEAD
✔ origin/main is now up-to-date
- Downloading patch for 64623
From https://github.com/nodejs/node
* branch refs/pull/64623/merge -> FETCH_HEAD
✔ Fetched commits as 7e439828de88..f3993733daf8
--------------------------------------------------------------------------------
Auto-merging doc/api/http2.md
[main d458cadee7] http2: increase default window sizes
Author: Matteo Collina <hello@matteocollina.com>
Date: Mon Jul 20 12:09:08 2026 +0000
16 files changed, 78 insertions(+), 61 deletions(-)
[main 2e28518bd9] http2: guard against null stream/req in OnStreamAfterReqFinished
Author: Matteo Collina <hello@matteocollina.com>
Date: Thu Jul 23 14:28:24 2026 +0000
1 file changed, 2 insertions(+)
[main 8974b46a94] http2: relax framesReceived assertion in perf_hooks test
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 08:19:42 2026 +0000
1 file changed, 5 insertions(+), 1 deletion(-)
[main 83d3ac6cb0] stream: fix pending_writes underflow in StreamPipe shutdown
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 11:03:27 2026 +0000
1 file changed, 13 insertions(+), 4 deletions(-)
[main 93ebe33adb] style: fix clang-format alignment in CHECK_EQ call
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 15:10:46 2026 +0000
1 file changed, 3 insertions(+), 5 deletions(-)
✔ Patches applied
There are 5 commits in the PR. Attempting autorebase.
(node:365) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Rebasing (2/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: increase default window sizes

Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).

The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.

Fixes: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 221808bb0e] http2: increase default window sizes
Author: Matteo Collina <hello@matteocollina.com>
Date: Mon Jul 20 12:09:08 2026 +0000
16 files changed, 78 insertions(+), 61 deletions(-)
Rebasing (3/10)
Rebasing (4/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: guard against null stream/req in OnStreamAfterReqFinished

When a stream is destroyed while a synchronous write is in flight
from StreamPipe::ProcessData, ReportWritesToJSStreamListener::
OnStreamAfterReqFinished can be called with a null stream_ or a
null req_wrap, causing a null pointer dereference. This race
becomes more likely with larger HTTP/2 windows (e.g., #38426)
because more data is in flight during session teardown.

Add early-return guards for both cases to prevent the crash.

Refs: #38426
Refs: #56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 83b091065d] http2: guard against null stream/req in OnStreamAfterReqFinished
Author: Matteo Collina <hello@matteocollina.com>
Date: Thu Jul 23 14:28:24 2026 +0000
1 file changed, 2 insertions(+)
Rebasing (5/10)
Rebasing (6/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: relax framesReceived assertion in perf_hooks test

With the default window size increase, the server sends an additional
WINDOW_UPDATE frame during session setup, increasing the frames received
by the client from 7 to 8 on some platforms. Relax the assertion to
check >= 7 instead of strict equality.

Refs: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 4a7c271e8b] http2: relax framesReceived assertion in perf_hooks test
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 08:19:42 2026 +0000
1 file changed, 5 insertions(+), 1 deletion(-)
Rebasing (7/10)
Rebasing (8/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
stream: fix pending_writes underflow in StreamPipe shutdown

When the writable sink is destroyed while there are still pending
writes, WritableListener::OnStreamDestroy previously reset
pending_writes_ to 0. This caused OnStreamAfterWrite to decrement
the counter below 0, making the pending_writes_ == 0 completion
check fail permanently — the oncomplete callback was never called,
causing a timeout.

Fix by:

  1. Not resetting pending_writes_ in OnStreamDestroy — let
    OnStreamAfterWrite track completion naturally.
  2. Using sink_destroyed_ flag in Unpipe to always remove the
    writable listener regardless of pending_writes_ count.
  3. Using <= 0 (instead of == 0) when sink_destroyed_ is set,
    and guarding RemoveStreamListener against a null stream.

This race became more likely with larger HTTP/2 windows (#38426)
because more writes are in flight when session teardown begins.

Refs: #38426
Refs: #56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 9d0e7f3fd7] stream: fix pending_writes underflow in StreamPipe shutdown
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 11:03:27 2026 +0000
1 file changed, 13 insertions(+), 4 deletions(-)
Rebasing (9/10)
Rebasing (10/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
style: fix clang-format alignment in CHECK_EQ call

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 6cbbcc670b] style: fix clang-format alignment in CHECK_EQ call
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 15:10:46 2026 +0000
1 file changed, 3 insertions(+), 5 deletions(-)
Successfully rebased and updated refs/heads/main.

ℹ Add commit-queue-squash label to land the PR as one commit, or commit-queue-rebase to land as separate commits.

https://github.com/nodejs/node/actions/runs/30825144898

@trivikrtrivikr removed the commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. label Aug 3, 2026
@trivikr

Copy link
Copy Markdown
Member

@mcollina This either needs commit-queue-squash or commit-queue-rebase

@mcollinamcollina added commit-queue-squash PRs the Commit Queue should land as one squashed commit. commit-queue PRs queued for automated landing through the Commit Queue. labels Aug 3, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 3, 2026
@aduh95aduh95 added the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 4, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 4, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 1576cb8 into nodejs:mainAug 4, 2026
82 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 1576cb8

aduh95 pushed a commit that referenced this pull request Aug 13, 2026
Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).
The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.
Fixes: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Sign up for freeto 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++.commit-queue-squashPRs the Commit Queue should land as one squashed commit.lib / srcIssues and PRs involving general changes in the lib/ or src/ directories.semver-majorPRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase HTTP/2 window size by default

13 participants

@mcollina@nodejs-github-bot@pimterry@Ethan-Arrowood@trivikr@jasnell@ronag@metcoder95@RafaelGSS@avivkeller@gurgunday@bjohansebas@aduh95
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

http2: increase default window sizes - #64623

Merged
nodejs-github-bot merged 5 commits into
nodejs:mainfrom
mcollina:increase-http2-window-size
Aug 4, 2026
Merged

http2: increase default window sizes#64623
nodejs-github-bot merged 5 commits into
nodejs:mainfrom
mcollina:increase-http2-window-size

Conversation

@mcollina

Copy link
Copy Markdown
Member

Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).

The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.

Fixes#38426

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

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

@nodejs-github-botnodejs-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 Jul 20, 2026
@mcollina
mcollina requested review from pimterry, ronag and trivikr and removed request for pimterryJuly 20, 2026 12:33
Comment threadsrc/node_http2.cc Outdated
// to window_size / RTT. With a 32MB connection window, throughput is
// significantly improved. See https://github.com/nodejs/node/issues/38426
CHECK_EQ(nghttp2_session_set_local_window_size(
session, NGHTTP2_FLAG_NONE, 0, 33554432), 0);

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.

There's a pre-existing issue that this exposes: you can't configure this in advance. You can only control the connection window with session.setLocalWindowSize once you have a session, but at that point this initial WINDOW_UPDATE has already been sent, and shrinking the window isn't effective as shown in the tests here (it just blocks further updates, it can't reduce what's already been sent). The stream window is configurable in advance (it's a SETTINGS parameter) but this connection window isn't.

That already existed implicitly but it was kind of OK when the initial window was small, but it's a real problem with a very large initial window I think, since there's basically no way to override this to make it any smaller again if you need to.

Can we add client & server options for this, so it can be configured before the first WINDOW_UPDATE is sent somehow?

Comment threadsrc/node_http2.cc Outdated
// to window_size / RTT. With a 32MB connection window, throughput is
// significantly improved. See https://github.com/nodejs/node/issues/38426
CHECK_EQ(nghttp2_session_set_local_window_size(
session, NGHTTP2_FLAG_NONE, 0, 33554432), 0);

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.

Nit: would be nicer to extract this as a constant

@codecov

codecovBot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.55556% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.16%. Comparing base (c8e2a82) to head (f399373).
⚠️ Report is 90 commits behind head on main.

Files with missing linesPatch %Lines
src/stream_pipe.cc0.00%4 Missing and 1 partial ⚠️
src/stream_base.cc0.00%0 Missing and 2 partials ⚠️
src/node_http2.cc0.00%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #64623 +/- ##
==========================================
- Coverage 90.16% 90.16% -0.01% 
==========================================
Files 746 746 Lines 242760 242773 +13 Branches 45765 45766 +1 ==========================================
+ Hits 218875 218885 +10 + Misses 15375 15368 -7 - Partials 8510 8520 +10 
Files with missing linesCoverage Δ
lib/internal/http2/core.js95.07% <100.00%> (+0.01%)⬆️
src/node_http2.h92.26% <ø> (ø)
src/node_http2.cc81.66% <0.00%> (-0.09%)⬇️
src/stream_base.cc79.74% <0.00%> (-0.30%)⬇️
src/stream_pipe.cc56.48% <0.00%> (-3.06%)⬇️

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

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch 2 times, most recently from 5c9bc03 to 4351b51CompareJuly 20, 2026 16:48
@mcollina

Copy link
Copy Markdown
MemberAuthor

Both addressed:

  1. Extracted DEFAULT_SETTINGS_LOCAL_CONNECTION_WINDOW_SIZE = 33554432 as a named constant in src/node_http2.h and used it in src/node_http2.cc.
  2. The pre-existing issue about not being able to configure the connection window in advance is noted — the initial WINDOW_UPDATE is sent at session creation before setLocalWindowSize can be called. This is a known limitation of the current API.

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from 4351b51 to 31761a0CompareJuly 20, 2026 18:25

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

Wouldn't it be semver-majorPRs that contain breaking changes and should be released in the next major version. ?

@mcollinamcollina added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jul 20, 2026
@mcollina

Copy link
Copy Markdown
MemberAuthor

yes

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch 3 times, most recently from 70882db to bd4cbd3CompareJuly 21, 2026 16:44
@pimterry

Copy link
Copy Markdown
Member

The pre-existing issue about not being able to configure the connection window in advance is noted — the initial WINDOW_UPDATE is sent at session creation before setLocalWindowSize can be called. This is a known limitation of the current API.

I do think this would be useful, but doesn't need to block this - I'll open a separate PR.

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from bd4cbd3 to 86b969bCompareJuly 21, 2026 22:16
@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from 86b969b to d0c68baCompareJuly 22, 2026 09:39

@Ethan-ArrowoodEthan-Arrowood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CI failure seems related to the change here; test-http2-respond-with-file-connection-abort is failing across multiple systems and that isn't a known flake. Leaving a request changes to this gets fixed before landing.

When a stream is destroyed while a synchronous write is in flight
from StreamPipe::ProcessData, ReportWritesToJSStreamListener::
OnStreamAfterReqFinished can be called with a null stream_ or a
null req_wrap, causing a null pointer dereference. This race
becomes more likely with larger HTTP/2 windows (e.g., nodejs#38426)
because more data is in flight during session teardown.
Add early-return guards for both cases to prevent the crash.
Refs: nodejs#38426
Refs: nodejs#56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
With the default window size increase, the server sends an additional
WINDOW_UPDATE frame during session setup, increasing the frames received
by the client from 7 to 8 on some platforms. Relax the assertion to
check >= 7 instead of strict equality.
Refs: nodejs#38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
When the writable sink is destroyed while there are still pending
writes, WritableListener::OnStreamDestroy previously reset
pending_writes_ to 0. This caused OnStreamAfterWrite to decrement
the counter below 0, making the pending_writes_ == 0 completion
check fail permanently — the oncomplete callback was never called,
causing a timeout.
Fix by:
1. Not resetting pending_writes_ in OnStreamDestroy — let
OnStreamAfterWrite track completion naturally.
2. Using sink_destroyed_ flag in Unpipe to always remove the
writable listener regardless of pending_writes_ count.
3. Using <= 0 (instead of == 0) when sink_destroyed_ is set,
and guarding RemoveStreamListener against a null stream.
This race became more likely with larger HTTP/2 windows (nodejs#38426)
because more writes are in flight when session teardown begins.
Refs: nodejs#38426
Refs: nodejs#56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from a25a676 to f399373CompareJuly 30, 2026 21:20
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 2, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mcollinamcollina added commit-queue PRs queued for automated landing through the Commit Queue. and removed needs-ci PRs that need a full CI run. labels Aug 3, 2026
@nodejs-github-botnodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Aug 3, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/64623
✔ Done loading data for nodejs/node/pull/64623
----------------------------------- PR info ------------------------------------
Title http2: increase default window sizes (#64623)
Author Matteo Collina <matteo.collina@gmail.com> (@mcollina)
Branch mcollina:increase-http2-window-size -> nodejs:main
Labels c++, semver-major, lib / src
Commits 5
- http2: increase default window sizes
- http2: guard against null stream/req in OnStreamAfterReqFinished
- http2: relax framesReceived assertion in perf_hooks test
- stream: fix pending_writes underflow in StreamPipe shutdown
- style: fix clang-format alignment in CHECK_EQ call
Committers 1
- Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
--------------------------------------------------------------------------------
ℹ This PR was created on Mon, 20 Jul 2026 12:33:00 GMT
✔ Approvals: 8
✔ - Rafael Gonzaga (@RafaelGSS) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4737957628
✔ - Tim Perry (@pimterry): https://github.com/nodejs/node/pull/64623#pullrequestreview-4765202215
✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4749623762
✔ - Gürgün Dayıoğlu (@gurgunday): https://github.com/nodejs/node/pull/64623#pullrequestreview-4765616109
✔ - Ethan Arrowood (@Ethan-Arrowood): https://github.com/nodejs/node/pull/64623#pullrequestreview-4767534645
✔ - Aviv Keller (@avivkeller): https://github.com/nodejs/node/pull/64623#pullrequestreview-4770440465
✔ - Robert Nagy (@ronag) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4838488304
✔ - Trivikram Kamat (@trivikr): https://github.com/nodejs/node/pull/64623#pullrequestreview-4841424027
✔ Last GitHub CI successful
ℹ Last Full PR CI on 2026-08-03T12:22:08Z: https://ci.nodejs.org/job/node-test-pull-request/75428/
- Querying data for job/node-test-pull-request/75428/
✔ Build data downloaded
✔ Last Jenkins CI successful
--------------------------------------------------------------------------------
✔ No git cherry-pick in progress
✔ No git am in progress
✔ No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
* branch main -> FETCH_HEAD
✔ origin/main is now up-to-date
- Downloading patch for 64623
From https://github.com/nodejs/node
* branch refs/pull/64623/merge -> FETCH_HEAD
✔ Fetched commits as 7e439828de88..f3993733daf8
--------------------------------------------------------------------------------
Auto-merging doc/api/http2.md
[main d458cadee7] http2: increase default window sizes
Author: Matteo Collina <hello@matteocollina.com>
Date: Mon Jul 20 12:09:08 2026 +0000
16 files changed, 78 insertions(+), 61 deletions(-)
[main 2e28518bd9] http2: guard against null stream/req in OnStreamAfterReqFinished
Author: Matteo Collina <hello@matteocollina.com>
Date: Thu Jul 23 14:28:24 2026 +0000
1 file changed, 2 insertions(+)
[main 8974b46a94] http2: relax framesReceived assertion in perf_hooks test
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 08:19:42 2026 +0000
1 file changed, 5 insertions(+), 1 deletion(-)
[main 83d3ac6cb0] stream: fix pending_writes underflow in StreamPipe shutdown
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 11:03:27 2026 +0000
1 file changed, 13 insertions(+), 4 deletions(-)
[main 93ebe33adb] style: fix clang-format alignment in CHECK_EQ call
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 15:10:46 2026 +0000
1 file changed, 3 insertions(+), 5 deletions(-)
✔ Patches applied
There are 5 commits in the PR. Attempting autorebase.
(node:365) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Rebasing (2/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: increase default window sizes

Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).

The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.

Fixes: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 221808bb0e] http2: increase default window sizes
Author: Matteo Collina <hello@matteocollina.com>
Date: Mon Jul 20 12:09:08 2026 +0000
16 files changed, 78 insertions(+), 61 deletions(-)
Rebasing (3/10)
Rebasing (4/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: guard against null stream/req in OnStreamAfterReqFinished

When a stream is destroyed while a synchronous write is in flight
from StreamPipe::ProcessData, ReportWritesToJSStreamListener::
OnStreamAfterReqFinished can be called with a null stream_ or a
null req_wrap, causing a null pointer dereference. This race
becomes more likely with larger HTTP/2 windows (e.g., #38426)
because more data is in flight during session teardown.

Add early-return guards for both cases to prevent the crash.

Refs: #38426
Refs: #56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 83b091065d] http2: guard against null stream/req in OnStreamAfterReqFinished
Author: Matteo Collina <hello@matteocollina.com>
Date: Thu Jul 23 14:28:24 2026 +0000
1 file changed, 2 insertions(+)
Rebasing (5/10)
Rebasing (6/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: relax framesReceived assertion in perf_hooks test

With the default window size increase, the server sends an additional
WINDOW_UPDATE frame during session setup, increasing the frames received
by the client from 7 to 8 on some platforms. Relax the assertion to
check >= 7 instead of strict equality.

Refs: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 4a7c271e8b] http2: relax framesReceived assertion in perf_hooks test
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 08:19:42 2026 +0000
1 file changed, 5 insertions(+), 1 deletion(-)
Rebasing (7/10)
Rebasing (8/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
stream: fix pending_writes underflow in StreamPipe shutdown

When the writable sink is destroyed while there are still pending
writes, WritableListener::OnStreamDestroy previously reset
pending_writes_ to 0. This caused OnStreamAfterWrite to decrement
the counter below 0, making the pending_writes_ == 0 completion
check fail permanently — the oncomplete callback was never called,
causing a timeout.

Fix by:

  1. Not resetting pending_writes_ in OnStreamDestroy — let
    OnStreamAfterWrite track completion naturally.
  2. Using sink_destroyed_ flag in Unpipe to always remove the
    writable listener regardless of pending_writes_ count.
  3. Using <= 0 (instead of == 0) when sink_destroyed_ is set,
    and guarding RemoveStreamListener against a null stream.

This race became more likely with larger HTTP/2 windows (#38426)
because more writes are in flight when session teardown begins.

Refs: #38426
Refs: #56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 9d0e7f3fd7] stream: fix pending_writes underflow in StreamPipe shutdown
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 11:03:27 2026 +0000
1 file changed, 13 insertions(+), 4 deletions(-)
Rebasing (9/10)
Rebasing (10/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
style: fix clang-format alignment in CHECK_EQ call

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 6cbbcc670b] style: fix clang-format alignment in CHECK_EQ call
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 15:10:46 2026 +0000
1 file changed, 3 insertions(+), 5 deletions(-)
Successfully rebased and updated refs/heads/main.

ℹ Add commit-queue-squash label to land the PR as one commit, or commit-queue-rebase to land as separate commits.

https://github.com/nodejs/node/actions/runs/30825144898

@trivikrtrivikr removed the commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. label Aug 3, 2026
@trivikr

Copy link
Copy Markdown
Member

@mcollina This either needs commit-queue-squash or commit-queue-rebase

@mcollinamcollina added commit-queue-squash PRs the Commit Queue should land as one squashed commit. commit-queue PRs queued for automated landing through the Commit Queue. labels Aug 3, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 3, 2026
@aduh95aduh95 added the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 4, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 4, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 1576cb8 into nodejs:mainAug 4, 2026
82 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 1576cb8

aduh95 pushed a commit that referenced this pull request Aug 13, 2026
Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).
The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.
Fixes: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Sign up for freeto 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++.commit-queue-squashPRs the Commit Queue should land as one squashed commit.lib / srcIssues and PRs involving general changes in the lib/ or src/ directories.semver-majorPRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase HTTP/2 window size by default

13 participants

@mcollina@nodejs-github-bot@pimterry@Ethan-Arrowood@trivikr@jasnell@ronag@metcoder95@RafaelGSS@avivkeller@gurgunday@bjohansebas@aduh95
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

http2: increase default window sizes - #64623

Merged
nodejs-github-bot merged 5 commits into
nodejs:mainfrom
mcollina:increase-http2-window-size
Aug 4, 2026
Merged

http2: increase default window sizes#64623
nodejs-github-bot merged 5 commits into
nodejs:mainfrom
mcollina:increase-http2-window-size

Conversation

@mcollina

Copy link
Copy Markdown
Member

Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).

The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.

Fixes#38426

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

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

@nodejs-github-botnodejs-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 Jul 20, 2026
@mcollina
mcollina requested review from pimterry, ronag and trivikr and removed request for pimterryJuly 20, 2026 12:33
Comment threadsrc/node_http2.cc Outdated
// to window_size / RTT. With a 32MB connection window, throughput is
// significantly improved. See https://github.com/nodejs/node/issues/38426
CHECK_EQ(nghttp2_session_set_local_window_size(
session, NGHTTP2_FLAG_NONE, 0, 33554432), 0);

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.

There's a pre-existing issue that this exposes: you can't configure this in advance. You can only control the connection window with session.setLocalWindowSize once you have a session, but at that point this initial WINDOW_UPDATE has already been sent, and shrinking the window isn't effective as shown in the tests here (it just blocks further updates, it can't reduce what's already been sent). The stream window is configurable in advance (it's a SETTINGS parameter) but this connection window isn't.

That already existed implicitly but it was kind of OK when the initial window was small, but it's a real problem with a very large initial window I think, since there's basically no way to override this to make it any smaller again if you need to.

Can we add client & server options for this, so it can be configured before the first WINDOW_UPDATE is sent somehow?

Comment threadsrc/node_http2.cc Outdated
// to window_size / RTT. With a 32MB connection window, throughput is
// significantly improved. See https://github.com/nodejs/node/issues/38426
CHECK_EQ(nghttp2_session_set_local_window_size(
session, NGHTTP2_FLAG_NONE, 0, 33554432), 0);

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.

Nit: would be nicer to extract this as a constant

@codecov

codecovBot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.55556% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.16%. Comparing base (c8e2a82) to head (f399373).
⚠️ Report is 90 commits behind head on main.

Files with missing linesPatch %Lines
src/stream_pipe.cc0.00%4 Missing and 1 partial ⚠️
src/stream_base.cc0.00%0 Missing and 2 partials ⚠️
src/node_http2.cc0.00%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #64623 +/- ##
==========================================
- Coverage 90.16% 90.16% -0.01% 
==========================================
Files 746 746 Lines 242760 242773 +13 Branches 45765 45766 +1 ==========================================
+ Hits 218875 218885 +10 + Misses 15375 15368 -7 - Partials 8510 8520 +10 
Files with missing linesCoverage Δ
lib/internal/http2/core.js95.07% <100.00%> (+0.01%)⬆️
src/node_http2.h92.26% <ø> (ø)
src/node_http2.cc81.66% <0.00%> (-0.09%)⬇️
src/stream_base.cc79.74% <0.00%> (-0.30%)⬇️
src/stream_pipe.cc56.48% <0.00%> (-3.06%)⬇️

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

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch 2 times, most recently from 5c9bc03 to 4351b51CompareJuly 20, 2026 16:48
@mcollina

Copy link
Copy Markdown
MemberAuthor

Both addressed:

  1. Extracted DEFAULT_SETTINGS_LOCAL_CONNECTION_WINDOW_SIZE = 33554432 as a named constant in src/node_http2.h and used it in src/node_http2.cc.
  2. The pre-existing issue about not being able to configure the connection window in advance is noted — the initial WINDOW_UPDATE is sent at session creation before setLocalWindowSize can be called. This is a known limitation of the current API.

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from 4351b51 to 31761a0CompareJuly 20, 2026 18:25

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

Wouldn't it be semver-majorPRs that contain breaking changes and should be released in the next major version. ?

@mcollinamcollina added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jul 20, 2026
@mcollina

Copy link
Copy Markdown
MemberAuthor

yes

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch 3 times, most recently from 70882db to bd4cbd3CompareJuly 21, 2026 16:44
@pimterry

Copy link
Copy Markdown
Member

The pre-existing issue about not being able to configure the connection window in advance is noted — the initial WINDOW_UPDATE is sent at session creation before setLocalWindowSize can be called. This is a known limitation of the current API.

I do think this would be useful, but doesn't need to block this - I'll open a separate PR.

@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from bd4cbd3 to 86b969bCompareJuly 21, 2026 22:16
@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from 86b969b to d0c68baCompareJuly 22, 2026 09:39

@Ethan-ArrowoodEthan-Arrowood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CI failure seems related to the change here; test-http2-respond-with-file-connection-abort is failing across multiple systems and that isn't a known flake. Leaving a request changes to this gets fixed before landing.

When a stream is destroyed while a synchronous write is in flight
from StreamPipe::ProcessData, ReportWritesToJSStreamListener::
OnStreamAfterReqFinished can be called with a null stream_ or a
null req_wrap, causing a null pointer dereference. This race
becomes more likely with larger HTTP/2 windows (e.g., nodejs#38426)
because more data is in flight during session teardown.
Add early-return guards for both cases to prevent the crash.
Refs: nodejs#38426
Refs: nodejs#56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
With the default window size increase, the server sends an additional
WINDOW_UPDATE frame during session setup, increasing the frames received
by the client from 7 to 8 on some platforms. Relax the assertion to
check >= 7 instead of strict equality.
Refs: nodejs#38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
When the writable sink is destroyed while there are still pending
writes, WritableListener::OnStreamDestroy previously reset
pending_writes_ to 0. This caused OnStreamAfterWrite to decrement
the counter below 0, making the pending_writes_ == 0 completion
check fail permanently — the oncomplete callback was never called,
causing a timeout.
Fix by:
1. Not resetting pending_writes_ in OnStreamDestroy — let
OnStreamAfterWrite track completion naturally.
2. Using sink_destroyed_ flag in Unpipe to always remove the
writable listener regardless of pending_writes_ count.
3. Using <= 0 (instead of == 0) when sink_destroyed_ is set,
and guarding RemoveStreamListener against a null stream.
This race became more likely with larger HTTP/2 windows (nodejs#38426)
because more writes are in flight when session teardown begins.
Refs: nodejs#38426
Refs: nodejs#56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina
mcollinaforce-pushed the increase-http2-window-size branch from a25a676 to f399373CompareJuly 30, 2026 21:20
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 2, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mcollinamcollina added commit-queue PRs queued for automated landing through the Commit Queue. and removed needs-ci PRs that need a full CI run. labels Aug 3, 2026
@nodejs-github-botnodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Aug 3, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/64623
✔ Done loading data for nodejs/node/pull/64623
----------------------------------- PR info ------------------------------------
Title http2: increase default window sizes (#64623)
Author Matteo Collina <matteo.collina@gmail.com> (@mcollina)
Branch mcollina:increase-http2-window-size -> nodejs:main
Labels c++, semver-major, lib / src
Commits 5
- http2: increase default window sizes
- http2: guard against null stream/req in OnStreamAfterReqFinished
- http2: relax framesReceived assertion in perf_hooks test
- stream: fix pending_writes underflow in StreamPipe shutdown
- style: fix clang-format alignment in CHECK_EQ call
Committers 1
- Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
--------------------------------------------------------------------------------
ℹ This PR was created on Mon, 20 Jul 2026 12:33:00 GMT
✔ Approvals: 8
✔ - Rafael Gonzaga (@RafaelGSS) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4737957628
✔ - Tim Perry (@pimterry): https://github.com/nodejs/node/pull/64623#pullrequestreview-4765202215
✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4749623762
✔ - Gürgün Dayıoğlu (@gurgunday): https://github.com/nodejs/node/pull/64623#pullrequestreview-4765616109
✔ - Ethan Arrowood (@Ethan-Arrowood): https://github.com/nodejs/node/pull/64623#pullrequestreview-4767534645
✔ - Aviv Keller (@avivkeller): https://github.com/nodejs/node/pull/64623#pullrequestreview-4770440465
✔ - Robert Nagy (@ronag) (TSC): https://github.com/nodejs/node/pull/64623#pullrequestreview-4838488304
✔ - Trivikram Kamat (@trivikr): https://github.com/nodejs/node/pull/64623#pullrequestreview-4841424027
✔ Last GitHub CI successful
ℹ Last Full PR CI on 2026-08-03T12:22:08Z: https://ci.nodejs.org/job/node-test-pull-request/75428/
- Querying data for job/node-test-pull-request/75428/
✔ Build data downloaded
✔ Last Jenkins CI successful
--------------------------------------------------------------------------------
✔ No git cherry-pick in progress
✔ No git am in progress
✔ No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
* branch main -> FETCH_HEAD
✔ origin/main is now up-to-date
- Downloading patch for 64623
From https://github.com/nodejs/node
* branch refs/pull/64623/merge -> FETCH_HEAD
✔ Fetched commits as 7e439828de88..f3993733daf8
--------------------------------------------------------------------------------
Auto-merging doc/api/http2.md
[main d458cadee7] http2: increase default window sizes
Author: Matteo Collina <hello@matteocollina.com>
Date: Mon Jul 20 12:09:08 2026 +0000
16 files changed, 78 insertions(+), 61 deletions(-)
[main 2e28518bd9] http2: guard against null stream/req in OnStreamAfterReqFinished
Author: Matteo Collina <hello@matteocollina.com>
Date: Thu Jul 23 14:28:24 2026 +0000
1 file changed, 2 insertions(+)
[main 8974b46a94] http2: relax framesReceived assertion in perf_hooks test
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 08:19:42 2026 +0000
1 file changed, 5 insertions(+), 1 deletion(-)
[main 83d3ac6cb0] stream: fix pending_writes underflow in StreamPipe shutdown
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 11:03:27 2026 +0000
1 file changed, 13 insertions(+), 4 deletions(-)
[main 93ebe33adb] style: fix clang-format alignment in CHECK_EQ call
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 15:10:46 2026 +0000
1 file changed, 3 insertions(+), 5 deletions(-)
✔ Patches applied
There are 5 commits in the PR. Attempting autorebase.
(node:365) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Rebasing (2/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: increase default window sizes

Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).

The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.

Fixes: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 221808bb0e] http2: increase default window sizes
Author: Matteo Collina <hello@matteocollina.com>
Date: Mon Jul 20 12:09:08 2026 +0000
16 files changed, 78 insertions(+), 61 deletions(-)
Rebasing (3/10)
Rebasing (4/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: guard against null stream/req in OnStreamAfterReqFinished

When a stream is destroyed while a synchronous write is in flight
from StreamPipe::ProcessData, ReportWritesToJSStreamListener::
OnStreamAfterReqFinished can be called with a null stream_ or a
null req_wrap, causing a null pointer dereference. This race
becomes more likely with larger HTTP/2 windows (e.g., #38426)
because more data is in flight during session teardown.

Add early-return guards for both cases to prevent the crash.

Refs: #38426
Refs: #56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 83b091065d] http2: guard against null stream/req in OnStreamAfterReqFinished
Author: Matteo Collina <hello@matteocollina.com>
Date: Thu Jul 23 14:28:24 2026 +0000
1 file changed, 2 insertions(+)
Rebasing (5/10)
Rebasing (6/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
http2: relax framesReceived assertion in perf_hooks test

With the default window size increase, the server sends an additional
WINDOW_UPDATE frame during session setup, increasing the frames received
by the client from 7 to 8 on some platforms. Relax the assertion to
check >= 7 instead of strict equality.

Refs: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 4a7c271e8b] http2: relax framesReceived assertion in perf_hooks test
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 08:19:42 2026 +0000
1 file changed, 5 insertions(+), 1 deletion(-)
Rebasing (7/10)
Rebasing (8/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
stream: fix pending_writes underflow in StreamPipe shutdown

When the writable sink is destroyed while there are still pending
writes, WritableListener::OnStreamDestroy previously reset
pending_writes_ to 0. This caused OnStreamAfterWrite to decrement
the counter below 0, making the pending_writes_ == 0 completion
check fail permanently — the oncomplete callback was never called,
causing a timeout.

Fix by:

  1. Not resetting pending_writes_ in OnStreamDestroy — let
    OnStreamAfterWrite track completion naturally.
  2. Using sink_destroyed_ flag in Unpipe to always remove the
    writable listener regardless of pending_writes_ count.
  3. Using <= 0 (instead of == 0) when sink_destroyed_ is set,
    and guarding RemoveStreamListener against a null stream.

This race became more likely with larger HTTP/2 windows (#38426)
because more writes are in flight when session teardown begins.

Refs: #38426
Refs: #56825
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 9d0e7f3fd7] stream: fix pending_writes underflow in StreamPipe shutdown
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 11:03:27 2026 +0000
1 file changed, 13 insertions(+), 4 deletions(-)
Rebasing (9/10)
Rebasing (10/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
style: fix clang-format alignment in CHECK_EQ call

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

[detached HEAD 6cbbcc670b] style: fix clang-format alignment in CHECK_EQ call
Author: Matteo Collina <hello@matteocollina.com>
Date: Fri Jul 24 15:10:46 2026 +0000
1 file changed, 3 insertions(+), 5 deletions(-)
Successfully rebased and updated refs/heads/main.

ℹ Add commit-queue-squash label to land the PR as one commit, or commit-queue-rebase to land as separate commits.

https://github.com/nodejs/node/actions/runs/30825144898

@trivikrtrivikr removed the commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. label Aug 3, 2026
@trivikr

Copy link
Copy Markdown
Member

@mcollina This either needs commit-queue-squash or commit-queue-rebase

@mcollinamcollina added commit-queue-squash PRs the Commit Queue should land as one squashed commit. commit-queue PRs queued for automated landing through the Commit Queue. labels Aug 3, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 3, 2026
@aduh95aduh95 added the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 4, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 4, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 1576cb8 into nodejs:mainAug 4, 2026
82 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 1576cb8

aduh95 pushed a commit that referenced this pull request Aug 13, 2026
Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).
The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.
Fixes: #38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64623
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Sign up for freeto 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++.commit-queue-squashPRs the Commit Queue should land as one squashed commit.lib / srcIssues and PRs involving general changes in the lib/ or src/ directories.semver-majorPRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase HTTP/2 window size by default

13 participants

@mcollina@nodejs-github-bot@pimterry@Ethan-Arrowood@trivikr@jasnell@ronag@metcoder95@RafaelGSS@avivkeller@gurgunday@bjohansebas@aduh95