Skip to content
Permalink
Browse files

http2: add test case for goaway

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 Nov 3, 2018
1 parent 2b0c853 commit 26f2eb8b125e568895c13be3c8e749b30cd70611
Showing with 27 additions and 0 deletions.
  1. +27 −0 test/parallel/test-http2-client-destroy.js
@@ -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 26f2eb8

Please sign in to comment.
You can’t perform that action at this time.