Skip to content

Commit c7f876b

Browse files
leeightBethGriggs
authored andcommitted
http2: fix session[kSession] undefined issue
`finishSessionDestroy` session cleanup when already done. PR-URL: #24547 Fixes: #24546 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ouyang Yadong <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent ec70330 commit c7f876b

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/internal/http2/core.js

+1
Original file line numberDiff line numberDiff line change
@@ -1996,6 +1996,7 @@ class Http2Stream extends Duplex {
19961996
// attempt to gracefully close the session.
19971997
const state = this[kState];
19981998
if (this.headersSent &&
1999+
this[kSession] &&
19992000
this[kSession][kType] === NGHTTP2_SESSION_SERVER &&
20002001
!(state.flags & STREAM_FLAGS_HAS_TRAILERS) &&
20012002
!state.didRead &&
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
const h2 = require('http2');
7+
8+
const server = h2.createServer();
9+
server.listen(0, common.localhostIPv4, common.mustCall(() => {
10+
const afterConnect = common.mustCall((session) => {
11+
session.request({ ':method': 'POST' }).end(common.mustCall(() => {
12+
session.destroy();
13+
server.close();
14+
}));
15+
});
16+
17+
const port = server.address().port;
18+
const host = common.localhostIPv4;
19+
h2.connect('http://' + host + ':' + port, afterConnect);
20+
}));

0 commit comments

Comments
 (0)