Skip to content

Commit 1dd744a

Browse files
davedoesdevdanielleadams
authored andcommitted
http2: fix error stream write followed by destroy
PR-URL: #35951 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ricky Zhou <0x19951125@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent cb6f0d3 commit 1dd744a

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

‎lib/internal/http2/core.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ function debugStream(id, sessionType, message, ...args) {
176176
}
177177

178178
functiondebugStreamObj(stream,message, ...args){
179-
debugStream(stream[kID],stream[kSession][kType],message, ...args);
179+
constsession=stream[kSession];
180+
consttype=session ? session[kType] : undefined;
181+
debugStream(stream[kID],type,message, ...args);
180182
}
181183

182184
functiondebugSession(sessionType,message, ...args){
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
constcommon=require('../common');
3+
if(!common.hasCrypto){
4+
common.skip('missing crypto');
5+
}
6+
7+
consthttp2=require('http2');
8+
constassert=require('assert');
9+
10+
constserver=http2.createServer();
11+
12+
server.on('session',common.mustCall(function(session){
13+
session.on('stream',common.mustCall(function(stream){
14+
stream.on('end',common.mustCall(function(){
15+
this.respond({
16+
':status': 200
17+
});
18+
this.write('foo');
19+
this.destroy();
20+
}));
21+
stream.resume();
22+
}));
23+
}));
24+
25+
server.listen(0,function(){
26+
constclient=http2.connect(`http://localhost:${server.address().port}`);
27+
conststream=client.request({':method': 'POST'});
28+
stream.on('response',common.mustCall(function(headers){
29+
assert.strictEqual(headers[':status'],200);
30+
}));
31+
stream.on('close',common.mustCall(()=>{
32+
client.close();
33+
server.close();
34+
}));
35+
stream.resume();
36+
stream.end();
37+
});

0 commit comments

Comments
 (0)