From 5dd65839a918e06aed3a16abe2e2392742e6c15b Mon Sep 17 00:00:00 2001 From: Trivikram Kamat Date: Sun, 24 Sep 2017 19:43:38 -0700 Subject: [PATCH] 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 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- ...st-http2-server-destroy-before-shutdown.js | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/parallel/test-http2-server-destroy-before-shutdown.js diff --git a/test/parallel/test-http2-server-destroy-before-shutdown.js b/test/parallel/test-http2-server-destroy-before-shutdown.js new file mode 100644 index 00000000000000..f6221c881528ef --- /dev/null +++ b/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())); +}));