Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3f15378

Browse filesBrowse files
ZYSzysBridgeAR
authored andcommitted
http2: set default maxConcurrentStreams
Set the default maxConcurrentStreams to NGHTTP2_DEFAULT_MAX_CONCURRENT_STREAMS. PR-URL: #29833 Fixes: #29763 Refs: nghttp2/nghttp2@16c4611 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
1 parent a5c2154 commit 3f15378
Copy full SHA for 3f15378

File tree

Expand file treeCollapse file tree

8 files changed

+19
-20
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

8 files changed

+19
-20
lines changed
Open diff view settings
Collapse file

‎doc/api/http2.md‎

Copy file name to clipboardExpand all lines: doc/api/http2.md
+6-2Lines changed: 6 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -2357,6 +2357,9 @@ server.on('stream', (stream, headers) => {
23572357
<!-- YAML
23582358
added: v8.4.0
23592359
changes:
2360+
- version: REPLACEME
2361+
pr-url: https://github.com/nodejs/node/pull/29833
2362+
description: The `maxConcurrentStreams` setting is stricter.
23602363
- version: v8.9.3
23612364
pr-url: https://github.com/nodejs/node/pull/16676
23622365
description: The `maxHeaderListSize` setting is now strictly enforced.
@@ -2382,9 +2385,10 @@ properties.
23822385
is 2<sup>24</sup>-1. **Default:** `16,384 bytes`.
23832386
* `maxConcurrentStreams` {number} Specifies the maximum number of concurrent
23842387
streams permitted on an `Http2Session`. There is no default value which
2385-
implies, at least theoretically, 2<sup>31</sup>-1 streams may be open
2388+
implies, at least theoretically, 2<sup>32</sup>-1 streams may be open
23862389
concurrently at any given time in an `Http2Session`. The minimum value
2387-
is 0. The maximum allowed value is 2<sup>31</sup>-1.
2390+
is 0. The maximum allowed value is 2<sup>32</sup>-1. **Default:**
2391+
`4294967295`.
23882392
* `maxHeaderListSize` {number} Specifies the maximum size (uncompressed octets)
23892393
of header list that will be accepted. The minimum allowed value is 0. The
23902394
maximum allowed value is 2<sup>32</sup>-1. **Default:** `65535`.
Collapse file

‎lib/internal/http2/core.js‎

Copy file name to clipboardExpand all lines: lib/internal/http2/core.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function debugSessionObj(session, message, ...args) {
161161

162162
const kMaxFrameSize = (2 ** 24) - 1;
163163
const kMaxInt = (2 ** 32) - 1;
164-
const kMaxStreams = (2 ** 31) - 1;
164+
const kMaxStreams = (2 ** 32) - 1;
165165
const kMaxALTSVC = (2 ** 14) - 2;
166166

167167
// eslint-disable-next-line no-control-regex
Collapse file

‎src/node_http2.cc‎

Copy file name to clipboardExpand all lines: src/node_http2.cc
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ void Http2Session::Http2Settings::RefreshDefaults(Environment* env) {
292292
DEFAULT_SETTINGS_HEADER_TABLE_SIZE;
293293
buffer[IDX_SETTINGS_ENABLE_PUSH] =
294294
DEFAULT_SETTINGS_ENABLE_PUSH;
295+
buffer[IDX_SETTINGS_MAX_CONCURRENT_STREAMS] =
296+
DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS;
295297
buffer[IDX_SETTINGS_INITIAL_WINDOW_SIZE] =
296298
DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE;
297299
buffer[IDX_SETTINGS_MAX_FRAME_SIZE] =
@@ -301,6 +303,7 @@ void Http2Session::Http2Settings::RefreshDefaults(Environment* env) {
301303
buffer[IDX_SETTINGS_COUNT] =
302304
(1 << IDX_SETTINGS_HEADER_TABLE_SIZE) |
303305
(1 << IDX_SETTINGS_ENABLE_PUSH) |
306+
(1 << IDX_SETTINGS_MAX_CONCURRENT_STREAMS) |
304307
(1 << IDX_SETTINGS_INITIAL_WINDOW_SIZE) |
305308
(1 << IDX_SETTINGS_MAX_FRAME_SIZE) |
306309
(1 << IDX_SETTINGS_MAX_HEADER_LIST_SIZE);
@@ -3233,6 +3236,7 @@ void Initialize(Local<Object> target,
32333236

32343237
NODE_DEFINE_CONSTANT(constants, DEFAULT_SETTINGS_HEADER_TABLE_SIZE);
32353238
NODE_DEFINE_CONSTANT(constants, DEFAULT_SETTINGS_ENABLE_PUSH);
3239+
NODE_DEFINE_CONSTANT(constants, DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS);
32363240
NODE_DEFINE_CONSTANT(constants, DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE);
32373241
NODE_DEFINE_CONSTANT(constants, DEFAULT_SETTINGS_MAX_FRAME_SIZE);
32383242
NODE_DEFINE_CONSTANT(constants, MAX_MAX_FRAME_SIZE);
Collapse file

‎src/node_http2.h‎

Copy file name to clipboardExpand all lines: src/node_http2.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ using performance::PerformanceEntry;
4040
// These are the standard HTTP/2 defaults as specified by the RFC
4141
#define DEFAULT_SETTINGS_HEADER_TABLE_SIZE 4096
4242
#define DEFAULT_SETTINGS_ENABLE_PUSH 1
43+
#define DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS 0xffffffffu
4344
#define DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE 65535
4445
#define DEFAULT_SETTINGS_MAX_FRAME_SIZE 16384
4546
#define DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE 65535
Collapse file

‎test/parallel/test-http2-binding.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-binding.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ assert.strictEqual(typeof binding.Http2Session, 'function');
1616
const settings = http2.getDefaultSettings();
1717
assert.strictEqual(settings.headerTableSize, 4096);
1818
assert.strictEqual(settings.enablePush, true);
19+
assert.strictEqual(settings.maxConcurrentStreams, 4294967295);
1920
assert.strictEqual(settings.initialWindowSize, 65535);
2021
assert.strictEqual(settings.maxFrameSize, 16384);
2122

@@ -227,6 +228,7 @@ const expectedNGConstants = {
227228
const defaultSettings = {
228229
DEFAULT_SETTINGS_HEADER_TABLE_SIZE: 4096,
229230
DEFAULT_SETTINGS_ENABLE_PUSH: 1,
231+
DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS: 4294967295,
230232
DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE: 65535,
231233
DEFAULT_SETTINGS_MAX_FRAME_SIZE: 16384
232234
};
Collapse file

‎test/parallel/test-http2-client-setNextStreamID-errors.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-client-setNextStreamID-errors.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ server.listen(0, common.mustCall(() => {
2626
const client = http2.connect(`http://localhost:${server.address().port}`);
2727

2828
client.on('connect', () => {
29-
const outOfRangeNum = 2 ** 31;
29+
const outOfRangeNum = 2 ** 32;
3030
common.expectsError(
3131
() => client.setNextStreamID(outOfRangeNum),
3232
{
3333
type: RangeError,
3434
code: 'ERR_OUT_OF_RANGE',
3535
message: 'The value of "id" is out of range.' +
36-
' It must be > 0 and <= 2147483647. Received ' + outOfRangeNum
36+
' It must be > 0 and <= 4294967295. Received ' + outOfRangeNum
3737
}
3838
);
3939

Collapse file

‎test/parallel/test-http2-client-settings-before-connect.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-client-settings-before-connect.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ server.listen(0, common.mustCall(() => {
2828
['maxFrameSize', 1, RangeError],
2929
['maxFrameSize', 2 ** 24, RangeError],
3030
['maxConcurrentStreams', -1, RangeError],
31-
['maxConcurrentStreams', 2 ** 31, RangeError],
31+
['maxConcurrentStreams', 2 ** 32, RangeError],
3232
['maxHeaderListSize', -1, RangeError],
3333
['maxHeaderListSize', 2 ** 32, RangeError],
3434
['enablePush', 'a', TypeError],
Collapse file

‎test/parallel/test-http2-getpackedsettings.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-getpackedsettings.js
+2-14Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const assert = require('assert');
77
const http2 = require('http2');
88

99
const check = Buffer.from([0x00, 0x01, 0x00, 0x00, 0x10, 0x00,
10+
0x00, 0x03, 0xff, 0xff, 0xff, 0xff,
1011
0x00, 0x05, 0x00, 0x00, 0x40, 0x00,
1112
0x00, 0x04, 0x00, 0x00, 0xff, 0xff,
1213
0x00, 0x06, 0x00, 0x00, 0xff, 0xff,
@@ -41,7 +42,7 @@ http2.getPackedSettings({ enablePush: false });
4142
['maxFrameSize', 16383],
4243
['maxFrameSize', 2 ** 24],
4344
['maxConcurrentStreams', -1],
44-
['maxConcurrentStreams', 2 ** 31],
45+
['maxConcurrentStreams', 2 ** 32],
4546
['maxHeaderListSize', -1],
4647
['maxHeaderListSize', 2 ** 32]
4748
].forEach((i) => {
@@ -168,16 +169,3 @@ http2.getPackedSettings({ enablePush: false });
168169
message: 'Invalid value for setting "maxFrameSize": 16777216'
169170
});
170171
}
171-
172-
// Check for maxConcurrentStreams failing the max number.
173-
{
174-
const packed = Buffer.from([0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xFF]);
175-
176-
common.expectsError(() => {
177-
http2.getUnpackedSettings(packed, { validate: true });
178-
}, {
179-
code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
180-
type: RangeError,
181-
message: 'Invalid value for setting "maxConcurrentStreams": 4294967295'
182-
});
183-
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.