perf(gateway): avoid single-chunk request body copy (#127783)

Amp-Thread-ID: https://ampcode.com/threads/T-01a021f5-984a-7628-a30c-491c166ff247

Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Peter Steinberger
2026-08-21 22:12:09 -07:00
committed by GitHub
parent 80beef6ff7
commit 15569b210e
+7 -1
View File
@@ -434,7 +434,13 @@ export async function readRequestBodyWithLimit(
const onEnd = () => {
ended = true;
finish(() => resolve(Buffer.concat(chunks).toString(encoding)));
finish(() =>
resolve(
chunks.length === 1
? chunks[0]!.toString(encoding)
: Buffer.concat(chunks).toString(encoding),
),
);
};
const onError = (error: Error) => {