From 5f85b5fdd487a92a6fd788b4363f1a946805f511 Mon Sep 17 00:00:00 2001 From: George Fu Date: Fri, 16 Aug 2024 13:53:35 -0400 Subject: [PATCH] fix(middleware-sdk-s3): skip stream inspection if non-stream-like body (#6333) --- 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;