@naturalcycles/firestore-lib 2.12.0 → 2.12.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.
|
@@ -65,7 +65,7 @@ export class FirestoreShardedReadable extends Readable {
|
|
|
65
65
|
}
|
|
66
66
|
void this.runNextQuery(shard).catch(err => {
|
|
67
67
|
this.logger.error('error in runNextQuery', err);
|
|
68
|
-
this.
|
|
68
|
+
this.destroy(err);
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
async runNextQuery(shard) {
|
|
@@ -155,7 +155,7 @@ export class FirestoreShardedReadable extends Readable {
|
|
|
155
155
|
table,
|
|
156
156
|
rowsRetrieved: this.rowsRetrieved,
|
|
157
157
|
}, err);
|
|
158
|
-
this.
|
|
158
|
+
this.destroy(err);
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
161
|
}
|
|
@@ -62,7 +62,7 @@ export class FirestoreStreamReadable extends Readable {
|
|
|
62
62
|
}
|
|
63
63
|
void this.runNextQuery().catch(err => {
|
|
64
64
|
this.logger.error('error in runNextQuery', err);
|
|
65
|
-
this.
|
|
65
|
+
this.destroy(err);
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
async runNextQuery() {
|
|
@@ -137,6 +137,7 @@ export class FirestoreStreamReadable extends Readable {
|
|
|
137
137
|
return await q.get();
|
|
138
138
|
}, {
|
|
139
139
|
name: `FirestoreStreamReadable.query(${table})`,
|
|
140
|
+
predicate: err => RETRY_ON.some(s => err?.message?.toLowerCase()?.includes(s)),
|
|
140
141
|
maxAttempts: 5,
|
|
141
142
|
delay: 5000,
|
|
142
143
|
delayMultiplier: 2,
|
|
@@ -149,8 +150,20 @@ export class FirestoreStreamReadable extends Readable {
|
|
|
149
150
|
table,
|
|
150
151
|
rowsRetrieved: this.rowsRetrieved,
|
|
151
152
|
}, err);
|
|
152
|
-
this.
|
|
153
|
+
this.destroy(err);
|
|
153
154
|
return;
|
|
154
155
|
}
|
|
155
156
|
}
|
|
156
157
|
}
|
|
158
|
+
// Examples of errors:
|
|
159
|
+
// UNKNOWN: Stream removed
|
|
160
|
+
const RETRY_ON = [
|
|
161
|
+
'GOAWAY',
|
|
162
|
+
'UNAVAILABLE',
|
|
163
|
+
'UNKNOWN',
|
|
164
|
+
'DEADLINE_EXCEEDED',
|
|
165
|
+
'ABORTED',
|
|
166
|
+
'much contention',
|
|
167
|
+
'try again',
|
|
168
|
+
'timeout',
|
|
169
|
+
].map(s => s.toLowerCase());
|
package/package.json
CHANGED
|
@@ -91,7 +91,7 @@ export class FirestoreShardedReadable<T extends ObjectWithId = any>
|
|
|
91
91
|
}
|
|
92
92
|
void this.runNextQuery(shard).catch(err => {
|
|
93
93
|
this.logger.error('error in runNextQuery', err)
|
|
94
|
-
this.
|
|
94
|
+
this.destroy(err)
|
|
95
95
|
})
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -213,7 +213,7 @@ export class FirestoreShardedReadable<T extends ObjectWithId = any>
|
|
|
213
213
|
},
|
|
214
214
|
err,
|
|
215
215
|
)
|
|
216
|
-
this.
|
|
216
|
+
this.destroy(err as Error)
|
|
217
217
|
return
|
|
218
218
|
}
|
|
219
219
|
}
|
|
@@ -85,7 +85,7 @@ export class FirestoreStreamReadable<T extends ObjectWithId = any>
|
|
|
85
85
|
|
|
86
86
|
void this.runNextQuery().catch(err => {
|
|
87
87
|
this.logger.error('error in runNextQuery', err)
|
|
88
|
-
this.
|
|
88
|
+
this.destroy(err)
|
|
89
89
|
})
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -177,6 +177,7 @@ export class FirestoreStreamReadable<T extends ObjectWithId = any>
|
|
|
177
177
|
},
|
|
178
178
|
{
|
|
179
179
|
name: `FirestoreStreamReadable.query(${table})`,
|
|
180
|
+
predicate: err => RETRY_ON.some(s => err?.message?.toLowerCase()?.includes(s)),
|
|
180
181
|
maxAttempts: 5,
|
|
181
182
|
delay: 5000,
|
|
182
183
|
delayMultiplier: 2,
|
|
@@ -193,8 +194,21 @@ export class FirestoreStreamReadable<T extends ObjectWithId = any>
|
|
|
193
194
|
},
|
|
194
195
|
err,
|
|
195
196
|
)
|
|
196
|
-
this.
|
|
197
|
+
this.destroy(err as Error)
|
|
197
198
|
return
|
|
198
199
|
}
|
|
199
200
|
}
|
|
200
201
|
}
|
|
202
|
+
|
|
203
|
+
// Examples of errors:
|
|
204
|
+
// UNKNOWN: Stream removed
|
|
205
|
+
const RETRY_ON = [
|
|
206
|
+
'GOAWAY',
|
|
207
|
+
'UNAVAILABLE',
|
|
208
|
+
'UNKNOWN',
|
|
209
|
+
'DEADLINE_EXCEEDED',
|
|
210
|
+
'ABORTED',
|
|
211
|
+
'much contention',
|
|
212
|
+
'try again',
|
|
213
|
+
'timeout',
|
|
214
|
+
].map(s => s.toLowerCase())
|