Skip to content

Commit

Permalink
fix(middleware-sdk-s3): fix error with partially-read Node.js streams (
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe authored Jul 21, 2024
1 parent fef3c33 commit e11de23
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/middleware-sdk-s3/src/throw-200-exceptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ export const throw200ExceptionsMiddleware =
return headStream(stream, MAX_BYTES_TO_INSPECT);
},
});
if (typeof bodyCopy?.destroy === "function") {
// discard partially-read Node.js Stream.
bodyCopy.destroy();
}

const bodyStringTail = config.utf8Encoder(bodyBytes.subarray(bodyBytes.length - 16));

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

0 comments on commit e11de23

Please sign in to comment.