From 58dcf30423c8ef9f28576ef299159c2de6e8df9b Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Tue, 8 Nov 2022 08:03:40 -0800 Subject: [PATCH] Apply fix(stream): Allows body larger than 16 KiB with middleware --- packages/next/server/body-streams.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/next/server/body-streams.ts b/packages/next/server/body-streams.ts index 7218529a660a4..1926b9357c589 100644 --- a/packages/next/server/body-streams.ts +++ b/packages/next/server/body-streams.ts @@ -90,8 +90,14 @@ export function getClonableBody( const input = buffered ?? readable const p1 = new PassThrough() const p2 = new PassThrough() - input.pipe(p1) - input.pipe(p2) + input.on('data', (chunk) => { + p1.push(chunk) + p2.push(chunk) + }) + input.on('end', () => { + p1.push(null) + p2.push(null) + }) buffered = p2 return p1 },