Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1dd744a

Browse filesBrowse 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
Copy full SHA for 1dd744a

File tree

Expand file treeCollapse file tree

2 files changed

+40
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+40
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/http2/core.js‎

Copy file name to clipboardExpand all lines: lib/internal/http2/core.js
+3-1Lines 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
function debugStreamObj(stream, message, ...args) {
179-
debugStream(stream[kID], stream[kSession][kType], message, ...args);
179+
const session = stream[kSession];
180+
const type = session ? session[kType] : undefined;
181+
debugStream(stream[kID], type, message, ...args);
180182
}
181183

182184
function debugSession(sessionType, message, ...args) {
Collapse file
+37Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
const common = require('../common');
3+
if (!common.hasCrypto) {
4+
common.skip('missing crypto');
5+
}
6+
7+
const http2 = require('http2');
8+
const assert = require('assert');
9+
10+
const server = 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+
const client = http2.connect(`http://localhost:${server.address().port}`);
27+
const stream = 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.