Skip to content

Commit 3855dc0

Browse files
author
connystrecker
committed
fix S3 Route: aggregate result promises to one promise
1 parent 695c9c4 commit 3855dc0

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/s3.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function process(s3Config, event, context) {
6161
return null;
6262
}
6363

64-
const results = [];
64+
const resultPromises = [];
6565
for (const record of event.Records) {
6666
for (const routeConfig of s3Config.routes) {
6767
const bucketNameMatched = matchConfigToEventValue(routeConfig.bucketName, record.s3.bucket.name);
@@ -74,16 +74,15 @@ function process(s3Config, event, context) {
7474
}
7575

7676
if (bucketNameMatched && eventNameMatched && objectKeyPrefixMatched) {
77-
const result = routeConfig.action(record, context);
78-
if (result) {
79-
results.push(result);
77+
const resultPromise = routeConfig.action(record, context);
78+
if (resultPromise) {
79+
resultPromises.push(resultPromise);
8080
}
8181
break;
8282
}
8383
}
8484
}
85-
86-
return results;
85+
return Promise.all(resultPromises);
8786
}
8887

8988
module.exports = process;

0 commit comments

Comments
 (0)