Skip to content

Commit 2caa3fe

Browse files
add error handling
1 parent c7ccab8 commit 2caa3fe

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

components/aws/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/aws",
3-
"version": "0.7.6",
3+
"version": "0.7.7",
44
"description": "Pipedream Aws Components",
55
"main": "aws.app.mjs",
66
"keywords": [

components/aws/sources/new-dynamodb-stream-event/new-dynamodb-stream-event.mjs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
name: "New DynamoDB Stream Event",
77
description: "Emit new event when a DynamoDB stream receives new events. [See the docs here](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_GetRecords.html)",
88
type: "source",
9-
version: "0.0.3",
9+
version: "0.0.4",
1010
dedupe: "unique",
1111
props: {
1212
...common.props,
@@ -75,21 +75,26 @@ export default {
7575
throw new Error("Stream is no longer enabled.");
7676
}
7777

78-
const shardIterator = this._getShardIterator() ?? (await this._getNewShardIterator());
78+
const shardIterator = this._getShardIterator();
7979

80-
const {
81-
Records: records, NextShardIterator: nextShardIterator,
82-
} = await this.getRecords({
83-
ShardIterator: shardIterator,
84-
});
80+
try {
81+
const {
82+
Records: records,
83+
NextShardIterator: nextShardIterator,
84+
} = await this.getRecords({
85+
ShardIterator: shardIterator,
86+
});
8587

86-
for (const record of records) {
87-
const meta = this.generateMeta(record);
88-
this.$emit(record, meta);
89-
}
88+
for (const record of records) {
89+
const meta = this.generateMeta(record);
90+
this.$emit(record, meta);
91+
}
9092

91-
if (nextShardIterator) {
9293
this._setShardIterator(nextShardIterator);
94+
} catch (e) {
95+
console.log("Error getting records", e);
96+
console.log("Retrieving a new shard iterator");
97+
await this._getNewShardIterator();
9398
}
9499
},
95100
};

0 commit comments

Comments
 (0)