GeezerVison is showing github.com — http2: fix error stream write followed by destroy · nodejs/node@92bd7b5
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/http2/core.js +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -167,7 +167,9 @@ function debugStream(id, sessionType, message, ...args) { |
167 | 167 | } |
168 | 168 |
|
169 | 169 | function debugStreamObj(stream, message, ...args) { |
170 | | - debugStream(stream[kID], stream[kSession][kType], message, ...args); |
| 170 | + const session = stream[kSession]; |
| 171 | + const type = session ? session[kType] : undefined; |
| 172 | + debugStream(stream[kID], type, message, ...args); |
171 | 173 | } |
172 | 174 |
|
173 | 175 | function debugSession(sessionType, message, ...args) { |
|
Collapse file
Copy file name to clipboard +37Lines changed: 37 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 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 | +}); |