Skip to content

Commit 857dfdb

Browse files
author
Phil Varner
committed
fix async sns post-ingest publishing
1 parent 2997c0d commit 857dfdb

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased] - TBD
9+
10+
### Fixed
11+
12+
- Post-ingest SNS topic was not being published to when deployed as a Lambda.
13+
814
## [2.0.0] - 2023-06-26
915

1016
### Removed

src/lambdas/ingest/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const handler = async (event, _context) => {
6767

6868
if (postIngestTopicArn) {
6969
logger.debug('Publishing to post-ingest topic: %s', postIngestTopicArn)
70-
publishResultsToSns(results, postIngestTopicArn)
70+
await publishResultsToSns(results, postIngestTopicArn)
7171
} else {
7272
logger.debug('Skkipping post-ingest notification since no topic is configured')
7373
}

src/lib/ingest.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ function updateLinksWithinRecord(record) {
187187
return record
188188
}
189189

190-
export function publishResultsToSns(results, topicArn) {
191-
results.forEach(async (result) => {
190+
export async function publishResultsToSns(results, topicArn) {
191+
await Promise.all(results.map(async (result) => {
192192
if (result.record && !result.error) {
193193
updateLinksWithinRecord(result.record)
194194
}
195195
await publishRecordToSns(topicArn, result.record, result.error)
196-
})
196+
}))
197197
}

0 commit comments

Comments
 (0)