Skip to content

Commit 7842f63

Browse files
trivikrMylesBorins
authored andcommitted
test: Http2Stream destroy server before shutdown
PR-URL: #15597 Refs: #14985 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent cc90283 commit 7842f63

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Flags: --expose-http2
2+
'use strict';
3+
4+
const common = require('../common');
5+
if (!common.hasCrypto)
6+
common.skip('missing crypto');
7+
const http2 = require('http2');
8+
9+
const server = http2.createServer();
10+
11+
// Test that ERR_HTTP2_INVALID_SESSION is thrown when a stream is destroyed
12+
// before calling stream.session.shutdown
13+
server.on('stream', common.mustCall((stream) => {
14+
stream.session.destroy();
15+
common.expectsError(
16+
() => stream.session.shutdown(),
17+
{
18+
type: Error,
19+
code: 'ERR_HTTP2_INVALID_SESSION',
20+
message: 'The session has been destroyed'
21+
}
22+
);
23+
}));
24+
25+
server.listen(0, common.mustCall(() => {
26+
const client = http2.connect(`http://localhost:${server.address().port}`);
27+
28+
const req = client.request();
29+
req.resume();
30+
req.on('end', common.mustCall(() => server.close()));
31+
}));

0 commit comments

Comments
 (0)