| 242 | const rawReader = response.body.getReader() |
| 243 | const reader: ReadableStreamDefaultReader<Uint8Array> = { |
| 244 | async read() { |
| 245 | const result = await rawReader.read() |
| 246 | if (!result.done && result.value) { |
| 247 | const now = performance.now() |
| 248 | const gap = now - counters.lastChunkMs |
| 249 | if (gap > counters.longestInboundGapMs) counters.longestInboundGapMs = gap |
| 250 | counters.lastChunkMs = now |
| 251 | counters.chunks += 1 |
| 252 | counters.bytes += result.value.byteLength |
| 253 | } |
| 254 | return result |
| 255 | }, |
| 256 | cancel: (reason) => rawReader.cancel(reason), |
| 257 | releaseLock: () => rawReader.releaseLock(), |
| 258 | get closed() { |