Skip to content

Commit

Permalink
test: Http2Stream destroy server before shutdown
Browse files Browse the repository at this point in the history
PR-URL: #15597
Refs: #14985
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
trivikr authored and MylesBorins committed Oct 3, 2017
1 parent 0aad7b1 commit 71897de
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/parallel/test-http2-server-destroy-before-shutdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Flags: --expose-http2
'use strict';

const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const http2 = require('http2');

const server = http2.createServer();

// Test that ERR_HTTP2_INVALID_SESSION is thrown when a stream is destroyed
// before calling stream.session.shutdown
server.on('stream', common.mustCall((stream) => {
stream.session.destroy();
common.expectsError(
() => stream.session.shutdown(),
{
type: Error,
code: 'ERR_HTTP2_INVALID_SESSION',
message: 'The session has been destroyed'
}
);
}));

server.listen(0, common.mustCall(() => {
const client = http2.connect(`http://localhost:${server.address().port}`);

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

0 comments on commit 71897de

Please sign in to comment.