presidium 0.29.7 → 0.29.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/DynamoStream.js CHANGED
@@ -82,6 +82,7 @@ const DynamoStream = function (options) {
82
82
  streamViewType: get('streamViewType', 'NEW_AND_OLD_IMAGES')(options)
83
83
  }) : {},
84
84
  ]))
85
+
85
86
  return this
86
87
  }
87
88
 
@@ -134,6 +135,15 @@ DynamoStream.prototype.getShards = async function* getShards(
134
135
  }
135
136
  }
136
137
 
138
+ // handleGetRecordsError(error Error) -> ()
139
+ const handleGetRecordsError = error => {
140
+ if (error.message.includes('Shard iterator has expired')) {
141
+ return []
142
+ }
143
+ throw error
144
+ }
145
+ DynamoStream.handleGetRecordsError = handleGetRecordsError
146
+
137
147
  // Shard => AsyncGenerator<Record>
138
148
  DynamoStream.prototype.getRecords = async function* getRecords(
139
149
  Shard,
@@ -155,7 +165,7 @@ DynamoStream.prototype.getRecords = async function* getRecords(
155
165
  let records = await this.retryGetRecords({
156
166
  ShardIterator: startingShardIterator,
157
167
  Limit: this.getRecordsLimit
158
- })
168
+ }).catch(handleGetRecordsError)
159
169
 
160
170
  if (records.Records.length > 0) {
161
171
  yield* records.Records.map(assign({
@@ -169,7 +179,7 @@ DynamoStream.prototype.getRecords = async function* getRecords(
169
179
  records = await this.retryGetRecords({
170
180
  ShardIterator: records.NextShardIterator,
171
181
  Limit: this.getRecordsLimit
172
- })
182
+ }).catch(handleGetRecordsError)
173
183
  if (records.Records.length > 0) {
174
184
  yield* records.Records.map(assign({
175
185
  table: always(this.table),
@@ -12,7 +12,11 @@ const ResourceNotFoundException = function (message) {
12
12
  return error
13
13
  }
14
14
 
15
- const test = Test('DynamoStream', DynamoStream)
15
+ const test0 = Test('DynamoStream.handleGetRecordsError', DynamoStream.handleGetRecordsError)
16
+ .case(new Error('Shard iterator has expired'), [])
17
+ .throws(new Error('other'), new Error('other'))
18
+
19
+ const test1 = Test('DynamoStream', DynamoStream)
16
20
 
17
21
  .before(async function () {
18
22
  const table = new DynamoTable({
@@ -320,6 +324,11 @@ const test = Test('DynamoStream', DynamoStream)
320
324
  myStream.close()
321
325
  })
322
326
 
327
+ const test = Test.all([
328
+ test0,
329
+ test1,
330
+ ])
331
+
323
332
  if (process.argv[1] == __filename) {
324
333
  test()
325
334
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "presidium",
3
- "version": "0.29.7",
3
+ "version": "0.29.8",
4
4
  "description": "A library for creating web services",
5
5
  "author": "Richard Tong",
6
6
  "license": "MIT",