Commit 3553da6
fix(firestore): bubble up errors in BulkWriter (#14481)
This PR addresses an issue where the Firestore `BulkWriter` could
silently fail to persist documents without notifying the caller. This
behavior was primarily observed when the `BulkWriter`'s context was
canceled or when internal limits were reached.
#### Root Causes
1. **Dropped Batches on Cancellation:** In the background `send`
function, if the context was canceled, the current batch of jobs was
dropped immediately without notifying the individual job result channels
.
2. **Ignored Queuing Errors:** The `write` function and the retry logic
ignored errors returned by the underlying bundler when attempting to
queue a write .
3. **Ignored Rate Limit Errors:** Context errors occurring during the
rate limiter's wait period were not checked or propagated .
#### Changes
- Updated the internal `write` method and its public callers (`Create`,
`Delete`, `Set`, and `Update`) to return errors from the rate limiter
and the bundler.
- Modified the `send` function to iterate through and notify all jobs in
a batch with a context error if the transmission is aborted due to
cancellation.
- Added error checking to the retry logic within `send` to ensure
failures to re-queue a job are surfaced.
These changes ensure that any failure to queue or send a document is
explicitly reported through the `BulkWriterJob` results or as an
immediate return value, preventing data loss.
#11422.
---------
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>1 parent 84d2146 commit 3553da6
2 files changed
Lines changed: 66 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
190 | 193 | | |
191 | 194 | | |
192 | 195 | | |
| |||
209 | 212 | | |
210 | 213 | | |
211 | 214 | | |
212 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
213 | 219 | | |
214 | 220 | | |
215 | 221 | | |
| |||
232 | 238 | | |
233 | 239 | | |
234 | 240 | | |
235 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
236 | 245 | | |
237 | 246 | | |
238 | 247 | | |
| |||
255 | 264 | | |
256 | 265 | | |
257 | 266 | | |
258 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
259 | 271 | | |
260 | 272 | | |
261 | 273 | | |
| |||
284 | 296 | | |
285 | 297 | | |
286 | 298 | | |
287 | | - | |
| 299 | + | |
288 | 300 | | |
289 | 301 | | |
290 | 302 | | |
291 | 303 | | |
292 | 304 | | |
293 | 305 | | |
294 | 306 | | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
299 | 314 | | |
300 | | - | |
| 315 | + | |
301 | 316 | | |
302 | 317 | | |
303 | 318 | | |
| |||
321 | 336 | | |
322 | 337 | | |
323 | 338 | | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
324 | 342 | | |
325 | 343 | | |
326 | 344 | | |
| |||
342 | 360 | | |
343 | 361 | | |
344 | 362 | | |
345 | | - | |
346 | | - | |
347 | | - | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
348 | 367 | | |
349 | 368 | | |
350 | 369 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
248 | 257 | | |
249 | 258 | | |
250 | 259 | | |
| |||
479 | 488 | | |
480 | 489 | | |
481 | 490 | | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
0 commit comments