Skip to content

Error thrown when empty map is present in firestore document #2204

@david0178418

Description

@david0178418

[REQUIRED] Describe your environment

  • Operating System version: Kubuntu 18.10
  • Browser version: Chrome 77.0.3865.90 (Official Build) (64-bit)
  • Firebase SDK version: 6.6.0
  • Firebase Product: firestore

[REQUIRED] Describe the problem

Error produced when empty map is present. Document.getProtoField incorrectly assumes a "fields" prop is present in mapValue. I don't know if this assumption is correct or if the mapValue should always have a "fields" property even if it is empty.

Method first appeared in firebase v6.6.0 as part of #2115

Steps to reproduce:

  1. Create a document containing an empty map
  2. Load the document in the firebase sdk

Expected Behavior: Loads data without error
Actual: Crashes

Adding a dummy prop works around the issue.

Relevant Code:

image

Full error:

    at Document.push../node_modules/@firebase/firestore/dist/index.cjs.js.Document.getProtoField (index.cjs.js:5792)
    at Document.push../node_modules/@firebase/firestore/dist/index.cjs.js.Document.field (index.cjs.js:5732)
    at FieldFilter.push../node_modules/@firebase/firestore/dist/index.cjs.js.FieldFilter.matches (index.cjs.js:14503)
    at Query.push../node_modules/@firebase/firestore/dist/index.cjs.js.Query.matchesFilters (index.cjs.js:14378)
    at Query.push../node_modules/@firebase/firestore/dist/index.cjs.js.Query.matches (index.cjs.js:14303)
    at index.cjs.js:6297
    at IDBRequest.cursorRequest.onsuccess [as __zone_symbol__ON_PROPERTYsuccess] (index.cjs.js:4121)
    at IDBRequest.wrapFn (zone-evergreen.js:1202)
    at ZoneDelegate.invokeTask (zone-evergreen.js:400)
    at Zone.runTask (zone-evergreen.js:168)
push../node_modules/@firebase/firestore/dist/index.cjs.js.Document.getProtoField @ index.cjs.js:5792
push../node_modules/@firebase/firestore/dist/index.cjs.js.Document.field @ index.cjs.js:5732
push../node_modules/@firebase/firestore/dist/index.cjs.js.FieldFilter.matches @ index.cjs.js:14503
push../node_modules/@firebase/firestore/dist/index.cjs.js.Query.matchesFilters @ index.cjs.js:14378
push../node_modules/@firebase/firestore/dist/index.cjs.js.Query.matches @ index.cjs.js:14303
(anonymous) @ index.cjs.js:6297
cursorRequest.onsuccess @ index.cjs.js:4121
wrapFn @ zone-evergreen.js:1202
invokeTask @ zone-evergreen.js:400
runTask @ zone-evergreen.js:168
invokeTask @ zone-evergreen.js:481
invokeTask @ zone-evergreen.js:1596
globalZoneAwareCallback @ zone-evergreen.js:1622
IndexedDB (async)
cursorRequest.onsuccess @ index.cjs.js:4133
wrapFn @ zone-evergreen.js:1202
invokeTask @ zone-evergreen.js:400
runTask @ zone-evergreen.js:168
invokeTask @ zone-evergreen.js:481
invokeTask @ zone-evergreen.js:1596
globalZoneAwareCallback @ zone-evergreen.js:1622
IndexedDB (async)
push../node_modules/@firebase/firestore/dist/index.cjs.js.SimpleDbStore.cursor @ index.cjs.js:4171
push../node_modules/@firebase/firestore/dist/index.cjs.js.SimpleDbStore.iterate @ index.cjs.js:4073
push../node_modules/@firebase/firestore/dist/index.cjs.js.IndexedDbRemoteDocumentCache.getDocumentsMatchingQuery @ index.cjs.js:6284
push../node_modules/@firebase/firestore/dist/index.cjs.js.LocalDocumentsView.getDocumentsMatchingCollectionQuery @ index.cjs.js:9136
push../node_modules/@firebase/firestore/dist/index.cjs.js.LocalDocumentsView.getDocumentsMatchingQuery @ index.cjs.js:9097
(anonymous) @ index.cjs.js:9874
(anonymous) @ index.cjs.js:8609
(anonymous) @ index.cjs.js:3030
push../node_modules/@firebase/firestore/dist/index.cjs.js.PersistencePromise.wrapUserFunction @ index.cjs.js:3016
push../node_modules/@firebase/firestore/dist/index.cjs.js.PersistencePromise.wrapSuccess @ index.cjs.js:3030
_this.nextCallback @ index.cjs.js:3000
(anonymous) @ index.cjs.js:2970
(anonymous) @ index.cjs.js:3030
push../node_modules/@firebase/firestore/dist/index.cjs.js.PersistencePromise.wrapUserFunction @ index.cjs.js:3016
push../node_modules/@firebase/firestore/dist/index.cjs.js.PersistencePromise.wrapSuccess @ index.cjs.js:3030
push../node_modules/@firebase/firestore/dist/index.cjs.js.PersistencePromise.next @ index.cjs.js:2991
_this.nextCallback @ index.cjs.js:3000
(anonymous) @ index.cjs.js:2970
(anonymous) @ index.cjs.js:3030
push../node_modules/@firebase/firestore/dist/index.cjs.js.PersistencePromise.wrapUserFunction @ index.cjs.js:3016
push../node_modules/@firebase/firestore/dist/index.cjs.js.PersistencePromise.wrapSuccess @ index.cjs.js:3030
push../node_modules/@firebase/firestore/dist/index.cjs.js.PersistencePromise.next @ index.cjs.js:2991
_this.nextCallback @ index.cjs.js:3000
(anonymous) @ index.cjs.js:2970
request.onsuccess @ index.cjs.js:4184
wrapFn @ zone-evergreen.js:1202
invokeTask @ zone-evergreen.js:400
runTask @ zone-evergreen.js:168
invokeTask @ zone-evergreen.js:481
invokeTask @ zone-evergreen.js:1596
globalZoneAwareCallback @ zone-evergreen.js:1622
IndexedDB (async)
push../node_modules/@firebase/firestore/dist/index.cjs.js.SimpleDbStore.get @ index.cjs.js:4013
push../node_modules/@firebase/firestore/dist/index.cjs.js.IndexedDbPersistence.verifyAllowTabSynchronization @ index.cjs.js:8623
(anonymous) @ index.cjs.js:8608
push../node_modules/@firebase/firestore/dist/index.cjs.js.SimpleDb.runTransaction @ index.cjs.js:3822
push../node_modules/@firebase/firestore/dist/index.cjs.js.IndexedDbPersistence.runTransaction @ index.cjs.js:8584
push../node_modules/@firebase/firestore/dist/index.cjs.js.LocalStore.executeQuery @ index.cjs.js:9873
(anonymous) @ index.cjs.js:17080
step @ tslib.es6.js:99
(anonymous) @ tslib.es6.js:80
(anonymous) @ tslib.es6.js:73
ZoneAwarePromise @ zone-evergreen.js:872
__awaiter @ tslib.es6.js:69
push../node_modules/@firebase/firestore/dist/index.cjs.js.SyncEngine.initializeViewAndComputeSnapshot @ index.cjs.js:17074
(anonymous) @ index.cjs.js:17055
step @ tslib.es6.js:99
(anonymous) @ tslib.es6.js:80
fulfilled @ tslib.es6.js:70
invoke @ zone-evergreen.js:365
run @ zone-evergreen.js:124
(anonymous) @ zone-evergreen.js:851
invokeTask @ zone-evergreen.js:400
runTask @ zone-evergreen.js:168
drainMicroTaskQueue @ zone-evergreen.js:570
invokeTask @ zone-evergreen.js:485
invokeTask @ zone-evergreen.js:1596
globalZoneAwareCallback @ zone-evergreen.js:1622

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions