@naturalcycles/datastore-lib 3.17.0 → 3.17.1
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/dist/datastore.db.js +3 -1
- package/package.json +1 -1
- package/src/datastore.db.ts +6 -1
package/dist/datastore.db.js
CHANGED
|
@@ -119,19 +119,21 @@ class DatastoreDB extends db_lib_1.BaseCommonDB {
|
|
|
119
119
|
// Here we retry the GOAWAY errors that are somewhat common for Datastore
|
|
120
120
|
// Currently only retrying them here in .saveBatch(), cause probably they're only thrown when saving
|
|
121
121
|
predicate: err => RETRY_ON.some(s => err?.message.includes(s)),
|
|
122
|
+
name: `DatastoreLib.saveBatch(${table})`,
|
|
122
123
|
maxAttempts: 5,
|
|
123
124
|
delay: 5000,
|
|
124
125
|
delayMultiplier: 2,
|
|
125
126
|
logFirstAttempt: false,
|
|
126
127
|
logFailures: true,
|
|
127
128
|
// logAll: true,
|
|
129
|
+
logger: this.cfg.logger,
|
|
128
130
|
});
|
|
129
131
|
try {
|
|
130
132
|
await (0, js_lib_1.pMap)((0, js_lib_1._chunk)(entities, MAX_ITEMS), async (batch) => await save(batch));
|
|
131
133
|
}
|
|
132
134
|
catch (err) {
|
|
133
135
|
// console.log(`datastore.save ${kind}`, { obj, entity })
|
|
134
|
-
this.cfg.logger.error(`error in
|
|
136
|
+
this.cfg.logger.error(`error in DatastoreLib.saveBatch for ${table} (${rows.length} rows)`, err);
|
|
135
137
|
// don't throw, because datastore SDK makes it in separate thread, so exception will be unhandled otherwise
|
|
136
138
|
return await Promise.reject(err);
|
|
137
139
|
}
|
package/package.json
CHANGED
package/src/datastore.db.ts
CHANGED
|
@@ -221,12 +221,14 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
|
|
|
221
221
|
// Here we retry the GOAWAY errors that are somewhat common for Datastore
|
|
222
222
|
// Currently only retrying them here in .saveBatch(), cause probably they're only thrown when saving
|
|
223
223
|
predicate: err => RETRY_ON.some(s => (err as Error)?.message.includes(s)),
|
|
224
|
+
name: `DatastoreLib.saveBatch(${table})`,
|
|
224
225
|
maxAttempts: 5,
|
|
225
226
|
delay: 5000,
|
|
226
227
|
delayMultiplier: 2,
|
|
227
228
|
logFirstAttempt: false,
|
|
228
229
|
logFailures: true,
|
|
229
230
|
// logAll: true,
|
|
231
|
+
logger: this.cfg.logger,
|
|
230
232
|
},
|
|
231
233
|
)
|
|
232
234
|
|
|
@@ -234,7 +236,10 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
|
|
|
234
236
|
await pMap(_chunk(entities, MAX_ITEMS), async batch => await save(batch))
|
|
235
237
|
} catch (err) {
|
|
236
238
|
// console.log(`datastore.save ${kind}`, { obj, entity })
|
|
237
|
-
this.cfg.logger.error(
|
|
239
|
+
this.cfg.logger.error(
|
|
240
|
+
`error in DatastoreLib.saveBatch for ${table} (${rows.length} rows)`,
|
|
241
|
+
err,
|
|
242
|
+
)
|
|
238
243
|
// don't throw, because datastore SDK makes it in separate thread, so exception will be unhandled otherwise
|
|
239
244
|
return await Promise.reject(err)
|
|
240
245
|
}
|