Skip to content

Commit

Permalink
test: robuster http2-large-file test
Browse files Browse the repository at this point in the history
This makes sure the first request is not sent before the client is
ready to respond. Therefore the ECONNRESET errors should be resolved.

Fixes: nodejs#22327
  • Loading branch information
BridgeAR committed Aug 26, 2018
1 parent ea8b932 commit 496cb1b
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions test/sequential/test-http2-large-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,25 @@ server.on('stream', (stream) => {
server.listen(0, common.mustCall(() => {
let remaining = 1e8;
const chunk = 1e6;
const client = http2.connect(`http://localhost:${server.address().port}`,
{ settings: { initialWindowSize: 6553500 } });
const request = client.request({ ':method': 'POST' });
function writeChunk() {
if (remaining > 0) {
remaining -= chunk;
request.write(Buffer.alloc(chunk, 'a'), writeChunk);
} else {
request.end();
http2.connect(
`http://localhost:${server.address().port}`,
{ settings: { initialWindowSize: 6553500 } },
(client) => {
const request = client.request({ ':method': 'POST' });
function writeChunk() {
if (remaining > 0) {
remaining -= chunk;
request.write(Buffer.alloc(chunk, 'a'), writeChunk);
} else {
request.end();
}
}
writeChunk();
request.on('close', common.mustCall(() => {
client.close();
server.close();
}));
request.resume();
}
}
writeChunk();
request.on('close', common.mustCall(() => {
client.close();
server.close();
}));
request.resume();
);
}));

0 comments on commit 496cb1b

Please sign in to comment.