Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: deflake test-http2-large-write-multiple-requests #51863

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion test/parallel/test-http2-large-write-multiple-requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

// This tests that the http2 server sends data early when it accumulates
// enough from ongoing requests to avoid DoS as mitigation for
// CVE-2019-9517 and CVE-2019-9511.
// Added by https://github.com/nodejs/node/commit/8a4a193
const fixtures = require('../common/fixtures');
const assert = require('assert');
const http2 = require('http2');
Expand All @@ -12,18 +16,21 @@ const content = fixtures.readSync('person-large.jpg');
const server = http2.createServer({
maxSessionMemory: 1000
});
let streamCount = 0;
server.on('stream', (stream, headers) => {
stream.respond({
'content-type': 'image/jpeg',
':status': 200
});
stream.end(content);
console.log('server sends content', ++streamCount);
});
server.unref();
joyeecheung marked this conversation as resolved.
Show resolved Hide resolved

server.listen(0, common.mustCall(() => {
const client = http2.connect(`http://localhost:${server.address().port}/`);

let endCount = 0;
let finished = 0;
for (let i = 0; i < 100; i++) {
const req = client.request({ ':path': '/' }).end();
Expand All @@ -32,8 +39,16 @@ server.listen(0, common.mustCall(() => {
chunks.push(chunk);
});
req.on('end', common.mustCall(() => {
console.log('client receives content', ++endCount);
assert.deepStrictEqual(Buffer.concat(chunks), content);
if (++finished === 100) client.close();

if (++finished === 100) {
client.close();
server.close();
}
}));
req.on('error', (e) => {
console.log('client error', e);
});
}
}));
Loading