@@ -180,22 +180,26 @@ 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+ }
183196
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- } ) ;
197+ Network . dataReceived ( {
198+ requestId : stream [ kInspectorRequestId ] ,
199+ timestamp : getMonotonicTime ( ) ,
200+ dataLength : chunk . byteLength ,
201+ encodedDataLength : chunk . byteLength ,
202+ data : chunk ,
199203 } ) ;
200204}
201205
@@ -228,4 +232,5 @@ module.exports = registerDiagnosticChannels([
228232 [ 'http2.client.stream.close' , onClientStreamClose ] ,
229233 [ 'http2.client.stream.bodyChunkSent' , onClientStreamBodyChunkSent ] ,
230234 [ 'http2.client.stream.bodySent' , onClientStreamBodySent ] ,
235+ [ 'stream.readable.addChunk' , onStreamReadableAddChunk ] ,
231236] ) ;
0 commit comments