Skip to content

Commit

Permalink
http2: fix session[kSession] undefined issue
Browse files Browse the repository at this point in the history
`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]>
  • Loading branch information
leeight authored and BethGriggs committed Feb 11, 2019
1 parent ec70330 commit c7f876b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1996,6 +1996,7 @@ class Http2Stream extends Duplex {
// attempt to gracefully close the session.
const state = this[kState];
if (this.headersSent &&
this[kSession] &&
this[kSession][kType] === NGHTTP2_SESSION_SERVER &&
!(state.flags & STREAM_FLAGS_HAS_TRAILERS) &&
!state.didRead &&
Expand Down
20 changes: 20 additions & 0 deletions test/parallel/test-http2-server-session-destroy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

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

const server = h2.createServer();
server.listen(0, common.localhostIPv4, common.mustCall(() => {
const afterConnect = common.mustCall((session) => {
session.request({ ':method': 'POST' }).end(common.mustCall(() => {
session.destroy();
server.close();
}));
});

const port = server.address().port;
const host = common.localhostIPv4;
h2.connect('http://' + host + ':' + port, afterConnect);
}));

0 comments on commit c7f876b

Please sign in to comment.