Skip to content

Commit 7a24232

Browse files
snobleclaude
andcommitted
fix: check Lambda execution errors in S3 uploader
The upload function now properly checks the result of lambda.send() and throws an exception when the Lambda execution fails. This ensures that errors from the batch processor are properly propagated up the call stack. The error handling follows the same pattern as script-function/index.ts: - Parses the error payload to extract errorType and errorMessage - Includes the source bucket/key in the error for better debugging - Uses the error.reason pattern consistent with the codebase 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 63d962f commit 7a24232

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/sst/support/custom-resources/s3-uploader.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ async function uploadFiles(props: Props) {
7777
fileOptions,
7878
replaceValues,
7979
} = props;
80-
await Promise.all(
80+
const results = await Promise.all(
8181
sources.map((source) =>
8282
lambda.send(
8383
new InvokeCommand({
@@ -96,6 +96,18 @@ async function uploadFiles(props: Props) {
9696
)
9797
)
9898
);
99+
100+
// Check for Lambda execution errors
101+
results.forEach((result, index) => {
102+
if (result.FunctionError) {
103+
const source = sources[index];
104+
const payload = JSON.parse(Buffer.from(result.Payload!).toString());
105+
const error = new Error();
106+
// @ts-ignore
107+
error.reason = `${payload.errorType}: ${payload.errorMessage} [${source.bucketName}/${source.objectKey}]`;
108+
throw error;
109+
}
110+
});
99111
}
100112

101113
async function purgeOldFiles(props: Props) {

0 commit comments

Comments
 (0)