Skip to content

Commit

Permalink
http2: add test case for goaway
Browse files Browse the repository at this point in the history
  • Loading branch information
antsmartian committed Nov 3, 2018
1 parent c979fad commit e60bbdc
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 e60bbdc

Please sign in to comment.