Skip to content

🎥 Make videos programmatically with React

Gracefully handle empty Lambda response payload, e.g. from rate limiting

Adam Jensendb4f73db8fb2
diff --git a/packages/lambda-client/src/call-lambda-sync.ts b/packages/lambda-client/src/call-lambda-sync.ts
index 92de15fb2a..b7a3dfb5b2 100644
--- a/packages/lambda-client/src/call-lambda-sync.ts
+++ b/packages/lambda-client/src/call-lambda-sync.ts
@@ -39,6 +39,12 @@ const callLambdaSyncWithoutRetry = async <
);
}
+ if (!res.Payload) {
+ throw new Error(
+ `Lambda function returned no payload (status ${res.StatusCode})`,
+ );
+ }
+
const decoded = new TextDecoder('utf-8').decode(res.Payload);
try {