+62
-0
lines changedFilter options
+62
-0
lines changed Original file line number Diff line number Diff line change
@@ -1217,6 +1217,13 @@ Emitted when a stream is created on the client.
1217
1217
1218
1218
Emitted when a stream is started on the client.
1219
1219
1220
+
`http2.client.stream.error`
1221
+
1222
+
* `stream` {ClientHttp2Stream}
1223
+
* `error` {Error}
1224
+
1225
+
Emitted when an error occurs during the processing of a stream on the client.
1226
+
1220
1227
#### Modules
1221
1228
1222
1229
> Stability: 1 - Experimental
Original file line number Diff line number Diff line change
@@ -187,6 +187,7 @@ const { _connectionListener: httpConnectionListener } = http;
187
187
const dc = require('diagnostics_channel');
188
188
const onClientStreamCreatedChannel = dc.channel('http2.client.stream.created');
189
189
const onClientStreamStartChannel = dc.channel('http2.client.stream.start');
190
+
const onClientStreamErrorChannel = dc.channel('http2.client.stream.error');
190
191
191
192
let debug = require('internal/util/debuglog').debuglog('http2', (fn) => {
192
193
debug = fn;
@@ -2424,6 +2425,14 @@ class Http2Stream extends Duplex {
2424
2425
setImmediate(() => {
2425
2426
session[kMaybeDestroy]();
2426
2427
});
2428
+
if (err &&
2429
+
session[kType] === NGHTTP2_SESSION_CLIENT &&
2430
+
onClientStreamErrorChannel.hasSubscribers) {
2431
+
onClientStreamErrorChannel.publish({
2432
+
stream: this,
2433
+
error: err,
2434
+
});
2435
+
}
2427
2436
callback(err);
2428
2437
}
2429
2438
// The Http2Stream can be destroyed if it has closed and if the readable
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
1
+
'use strict';
2
+
3
+
const common = require('../common');
4
+
if (!common.hasCrypto)
5
+
common.skip('missing crypto');
6
+
7
+
// This test ensures that the built-in HTTP/2 diagnostics channels are reporting
8
+
// the diagnostics messages for the 'http2.client.stream.error' channel when
9
+
// an error occurs during the processing of a ClientHttp2Stream.
10
+
11
+
const assert = require('assert');
12
+
const dc = require('diagnostics_channel');
13
+
const http2 = require('http2');
14
+
const { Duplex } = require('stream');
15
+
16
+
dc.subscribe('http2.client.stream.error', common.mustCall(({ stream, error }) => {
17
+
// Since ClientHttp2Stream is not exported from any module, this just checks
18
+
// if the stream is an instance of Duplex and the constructor name is
19
+
// 'ClientHttp2Stream'.
20
+
assert.ok(stream instanceof Duplex);
21
+
assert.strictEqual(stream.constructor.name, 'ClientHttp2Stream');
22
+
assert.strictEqual(stream.closed, true);
23
+
assert.strictEqual(stream.destroyed, true);
24
+
25
+
assert.ok(error);
26
+
assert.strictEqual(error.code, 'ABORT_ERR');
27
+
assert.strictEqual(error.name, 'AbortError');
28
+
}));
29
+
30
+
const server = http2.createServer();
31
+
server.listen(0, common.mustCall(() => {
32
+
const port = server.address().port;
33
+
const client = http2.connect(`http://localhost:${port}`);
34
+
35
+
const ac = new AbortController();
36
+
const stream = client.request({}, { signal: ac.signal });
37
+
ac.abort();
38
+
39
+
stream.on('error', common.mustCall((err) => {
40
+
assert.strictEqual(err.code, 'ABORT_ERR');
41
+
assert.strictEqual(err.name, 'AbortError');
42
+
43
+
client.close();
44
+
server.close();
45
+
}));
46
+
}));
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4