Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,29 @@ export const flexibleChecksumsMiddleware =
}
}

const result = await next({
...args,
request: {
...request,
headers: updatedHeaders,
body: updatedBody,
},
});
try {
const result = await next({
...args,
request: {
...request,
headers: updatedHeaders,
body: updatedBody,
},
});

return result;
return result;
} catch (e: unknown) {
if (e instanceof Error && e.name === "InvalidChunkSizeError") {
try {
if (!e.message.endsWith(".")) {
e.message += ".";
}
e.message +=
" Set [requestStreamBufferSize=number e.g. 65_536] in client constructor to instruct AWS SDK to buffer your input stream.";
} catch (ignored) {
// e.g. message property unwritable.
}
}
throw e;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ describe("S3 checksums", () => {
})
.catch((e) => {
expect(String(e)).toContain(
"InvalidChunkSizeError: Only the last chunk is allowed to have a size less than 8192 bytes"
"InvalidChunkSizeError: Only the last chunk is allowed to have a size less than 8192 bytes. " +
"Set [requestStreamBufferSize=number e.g. 65_536] in client constructor to instruct AWS SDK to buffer your input stream."
);
});
expect.hasAssertions();
Expand Down
Loading