Skip to content

Commit e11de23

Browse files
authored
fix(middleware-sdk-s3): fix error with partially-read Node.js streams (#6294)
1 parent fef3c33 commit e11de23

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/middleware-sdk-s3/src/throw-200-exceptions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ export const throw200ExceptionsMiddleware =
6262
return headStream(stream, MAX_BYTES_TO_INSPECT);
6363
},
6464
});
65+
if (typeof bodyCopy?.destroy === "function") {
66+
// discard partially-read Node.js Stream.
67+
bodyCopy.destroy();
68+
}
69+
6570
const bodyStringTail = config.utf8Encoder(bodyBytes.subarray(bodyBytes.length - 16));
6671

6772
// Throw on 200 response with empty body, legacy behavior allowlist.

0 commit comments

Comments
 (0)