@pbvision/firestore-orm 0.0.19 → 0.0.20

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/context.js +5 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pbvision/firestore-orm",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "description": "Firestore ORM Library",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
package/src/context.js CHANGED
@@ -543,6 +543,7 @@ export class Context {
543
543
  await this.__eventEmitter.emit(this.constructor.EVENTS.POST_COMMIT)
544
544
  return ret
545
545
  } catch (originalErr) {
546
+ console.warn('caught error while trying to run the transaction', originalErr)
546
547
  const firestoreError = parseFirestoreError(originalErr)
547
548
  err = firestoreError ?? originalErr
548
549
 
@@ -633,11 +634,13 @@ export class Context {
633
634
  function parseFirestoreError (err) {
634
635
  // probably a firestore error if it has these fields
635
636
  if (err.code && err.details) {
636
- // error 10 is the "Transaction lock timeout" error; retryable if separate
637
+ console.log(`trying to parse firestore error code=${err.code} details=${err.details}`)
638
+ // error 10 is the "Transaction lock timeout" aka
639
+ // "Optimistic transaction was aborted" error; retryable if separate
637
640
  // transactions got in each other's way but could succeed if ordered
638
641
  // differently (this error happens with pessimistic locking, the default
639
642
  // Firestore setting)
640
- if (err.code === 10 && err.details.indexOf('lock') !== -1) {
643
+ if (err.code === 10) {
641
644
  return new TransactionLockTimeoutError(err.message, err)
642
645
  }
643
646