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 d85e400

Browse filesBrowse files
addaleaxBethGriggs
authored andcommitted
test: apply test-http2-max-session-memory-leak from v12.x
Refs: #27914 Backport-PR-URL: #29123 PR-URL: #29122 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 0acbe05 commit d85e400
Copy full SHA for d85e400

File tree

Expand file treeCollapse file tree

1 file changed

+46
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+46
-0
lines changed
Open diff view settings
Collapse file
+46Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
'use strict';
2+
const common = require('../common');
3+
if (!common.hasCrypto)
4+
common.skip('missing crypto');
5+
const http2 = require('http2');
6+
7+
// Regression test for https://github.com/nodejs/node/issues/27416.
8+
// Check that received data is accounted for correctly in the maxSessionMemory
9+
// mechanism.
10+
11+
const bodyLength = 8192;
12+
const maxSessionMemory = 1; // 1 MB
13+
const requestCount = 1000;
14+
15+
const server = http2.createServer({ maxSessionMemory });
16+
server.on('stream', (stream) => {
17+
stream.respond();
18+
stream.end();
19+
});
20+
21+
server.listen(common.mustCall(() => {
22+
const client = http2.connect(`http://localhost:${server.address().port}`, {
23+
maxSessionMemory
24+
});
25+
26+
function request() {
27+
return new Promise((resolve, reject) => {
28+
const stream = client.request({
29+
':method': 'POST',
30+
'content-length': bodyLength
31+
});
32+
stream.on('error', reject);
33+
stream.on('response', resolve);
34+
stream.end('a'.repeat(bodyLength));
35+
});
36+
}
37+
38+
(async () => {
39+
for (let i = 0; i < requestCount; i++) {
40+
await request();
41+
}
42+
43+
client.close();
44+
server.close();
45+
})().then(common.mustCall());
46+
}));

0 commit comments

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