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 addaleax committed Jan 14, 2019
1 parent 2b0c853 commit 26f2eb8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/parallel/test-http2-client-destroy.js
Expand Up @@ -137,3 +137,30 @@ const Countdown = require('../common/countdown');
req.destroy(); 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 26f2eb8

Please sign in to comment.