Skip to content

Commit 2a2577b

Browse files
committed
Revert "stream: add diagnostics channel for tracking chunks added to a readable stream"
This reverts commit a6c2fce.
1 parent a6c2fce commit 2a2577b

File tree

3 files changed

+15
-41
lines changed

3 files changed

+15
-41
lines changed

doc/api/diagnostics_channel.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,17 +1399,6 @@ Emitted when [`net.Server.listen()`][] is returning an error.
13991399

14001400
Emitted when a new UDP socket is created.
14011401

1402-
#### Stream
1403-
1404-
> Stability: 1 - Experimental
1405-
1406-
##### Event: `'stream.readable.addChunk'`
1407-
1408-
* `stream` {stream.Readable}
1409-
* `chunk` {Buffer}
1410-
1411-
Emitted when a chunk is added to a readable stream.
1412-
14131402
#### Process
14141403

14151404
> Stability: 1 - Experimental

lib/internal/inspector/network_http2.js

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -180,26 +180,22 @@ function onClientStreamFinish({ stream, headers }) {
180180
charset,
181181
},
182182
});
183-
}
184-
185-
/**
186-
* When a chunk of the response body has been received, cache it until `getResponseBody` request
187-
* https://chromedevtools.github.io/devtools-protocol/1-3/Network/#method-getResponseBody or
188-
* stream it with `streamResourceContent` request.
189-
* https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-streamResourceContent
190-
* @param {{ stream: import('http2').ClientHttp2Stream, chunk: Buffer }} event
191-
*/
192-
function onStreamReadableAddChunk({ stream, chunk }) {
193-
if (typeof stream[kInspectorRequestId] !== 'string') {
194-
return;
195-
}
196183

197-
Network.dataReceived({
198-
requestId: stream[kInspectorRequestId],
199-
timestamp: getMonotonicTime(),
200-
dataLength: chunk.byteLength,
201-
encodedDataLength: chunk.byteLength,
202-
data: chunk,
184+
stream.on('data', (chunk) => {
185+
/**
186+
* When a chunk of the response body has been received, cache it until `getResponseBody` request
187+
* https://chromedevtools.github.io/devtools-protocol/1-3/Network/#method-getResponseBody or
188+
* stream it with `streamResourceContent` request.
189+
* https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-streamResourceContent
190+
*/
191+
192+
Network.dataReceived({
193+
requestId: stream[kInspectorRequestId],
194+
timestamp: getMonotonicTime(),
195+
dataLength: chunk.byteLength,
196+
encodedDataLength: chunk.byteLength,
197+
data: chunk,
198+
});
203199
});
204200
}
205201

@@ -232,5 +228,4 @@ module.exports = registerDiagnosticChannels([
232228
['http2.client.stream.close', onClientStreamClose],
233229
['http2.client.stream.bodyChunkSent', onClientStreamBodyChunkSent],
234230
['http2.client.stream.bodySent', onClientStreamBodySent],
235-
['stream.readable.addChunk', onStreamReadableAddChunk],
236231
]);

lib/internal/streams/readable.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ const FastBuffer = Buffer[SymbolSpecies];
9292
const { StringDecoder } = require('string_decoder');
9393
const from = require('internal/streams/from');
9494

95-
const dc = require('diagnostics_channel');
96-
const onAddChunkChannel = dc.channel('stream.readable.addChunk');
97-
9895
ObjectSetPrototypeOf(Readable.prototype, Stream.prototype);
9996
ObjectSetPrototypeOf(Readable, Stream);
10097
const nop = () => {};
@@ -549,13 +546,6 @@ function canPushMore(state) {
549546
}
550547

551548
function addChunk(stream, state, chunk, addToFront) {
552-
if (onAddChunkChannel.hasSubscribers) {
553-
onAddChunkChannel.publish({
554-
stream,
555-
chunk,
556-
});
557-
}
558-
559549
if ((state[kState] & (kFlowing | kSync | kDataListening)) === (kFlowing | kDataListening) && state.length === 0) {
560550
// Use the guard to avoid creating `Set()` repeatedly
561551
// when we have multiple pipes.

0 commit comments

Comments
 (0)