From 4f37ad1c1638b86c391c0ace2b49563807eddf59 Mon Sep 17 00:00:00 2001 From: George Fu Date: Tue, 30 Jul 2024 00:54:03 +0000 Subject: [PATCH] fix(middleware-sdk-s3): skip stream inspection if non-stream-like body --- packages/middleware-sdk-s3/src/throw-200-exceptions.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/middleware-sdk-s3/src/throw-200-exceptions.ts b/packages/middleware-sdk-s3/src/throw-200-exceptions.ts index 487438c3b54b..ccef9b8910fa 100644 --- a/packages/middleware-sdk-s3/src/throw-200-exceptions.ts +++ b/packages/middleware-sdk-s3/src/throw-200-exceptions.ts @@ -48,6 +48,15 @@ export const throw200ExceptionsMiddleware = return result; } + const isSplittableStream = + typeof sourceBody?.stream === "function" || + typeof sourceBody?.pipe === "function" || + typeof sourceBody?.tee === "function"; + + if (!isSplittableStream) { + return result; + } + let bodyCopy = sourceBody; let body = sourceBody;