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: fix flaky test-http2-client-upload #29889

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 11 additions & 6 deletions test/parallel/test-http2-client-upload.js
Expand Up @@ -21,24 +21,29 @@ fs.readFile(loc, common.mustCall((err, data) => {
fileData = data;

const server = http2.createServer();
let client;

const countdown = new Countdown(3, () => {
server.close();
client.close();
});

server.on('stream', common.mustCall((stream) => {
let data = Buffer.alloc(0);
stream.on('data', (chunk) => data = Buffer.concat([data, chunk]));
stream.on('end', common.mustCall(() => {
assert.deepStrictEqual(data, fileData);
}));
// Waiting on close avoids spurious ECONNRESET seen in windows CI.
// Not sure if this is actually a bug; more details at
// https://github.com/nodejs/node/issues/20750#issuecomment-511015247
stream.on('close', () => countdown.dec());
stream.respond();
stream.end();
}));

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

const countdown = new Countdown(2, () => {
server.close();
client.close();
});
client = http2.connect(`http://localhost:${server.address().port}`);

const req = client.request({ ':method': 'POST' });
req.on('response', common.mustCall());
Expand Down