Browse Source

test: Http2Stream destroy server before shutdown

PR-URL: https://github.com/nodejs/node/pull/15597
Refs: https://github.com/nodejs/node/issues/14985
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
v9.x-staging
Trivikram Kamat 8 years ago
committed by Ruben Bridgewater
parent
commit
5dd65839a9
No known key found for this signature in database GPG Key ID: F07496B3EB3C1762
  1. 30
      test/parallel/test-http2-server-destroy-before-shutdown.js

30
test/parallel/test-http2-server-destroy-before-shutdown.js

@ -0,0 +1,30 @@
'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()));
}));
Loading…
Cancel
Save