Skip to content

Commit

Permalink
http2: add test case for goaway
Browse files Browse the repository at this point in the history
PR-URL: #24054
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
antsmartian authored and MylesBorins committed May 16, 2019
1 parent 07f878b commit ba6829d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/parallel/test-http2-client-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,30 @@ const Countdown = require('../common/countdown');
req.destroy();
}));
}

// test close before connect
{
const server = h2.createServer();

server.on('stream', common.mustNotCall());
server.listen(0, common.mustCall(() => {
const client = h2.connect(`http://localhost:${server.address().port}`);
const socket = client[kSocket];
socket.on('close', common.mustCall(() => {
assert(socket.destroyed);
}));

const req = client.request();
// should throw goaway error
req.on('error', common.expectsError({
code: 'ERR_HTTP2_GOAWAY_SESSION',
type: Error,
message: 'New streams cannot be created after receiving a GOAWAY'
}));

client.close();
req.resume();
req.on('end', common.mustCall());
req.on('close', common.mustCall(() => server.close()));
}));
}

0 comments on commit ba6829d

Please sign in to comment.