From 11aa161c039a84651f7c75ac4217adf187e7b82f Mon Sep 17 00:00:00 2001 From: adstep Date: Tue, 13 Oct 2026 18:57:24 -0700 Subject: [PATCH] benchmarks: propagate S3 GET stream errors through byte counter Copilot-Session: c3579153-958b-482e-bd14-025a1a9c09af --- benchmarks/src/metrics.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/benchmarks/src/metrics.js b/benchmarks/src/metrics.js index 831998f..629048b 100644 --- a/benchmarks/src/metrics.js +++ b/benchmarks/src/metrics.js @@ -1,5 +1,5 @@ import * as fs from 'node:fs' -import { Transform } from 'node:stream' +import { Readable } from 'node:stream' import { monitorEventLoopDelay } from 'node:perf_hooks' /** @@ -66,12 +66,13 @@ export const countS3Ops = (plugin, counters) => { client.getObject = async (...args) => { counters.gets++ const stream = await get(...args) - // count through a Transform rather than a 'data' listener: a listener would - // put the stream into flowing mode and race the caller's `for await` - const counting = new Transform({ - transform (chunk, _enc, cb) { counters.getBytes += chunk.length; cb(null, chunk) } - }) - return stream.pipe(counting) + const counted = async function * () { + for await (const chunk of stream) { + counters.getBytes += chunk.length + yield chunk + } + } + return Readable.from(counted()) } /** @param {any[]} args */ client.removeObject = (...args) => {