Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
david0178418 opened this issue Sep 27, 2019 · 3 comments · Fixed by #2206
Closed

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

david0178418 opened this issue Sep 27, 2019 · 3 comments · Fixed by #2206
Assignees

Comments

@david0178418
Copy link

[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
@mikelehen
Copy link
Contributor

@david0178418 Thanks very much for the bug report and for tracking down the PR that caused it. 😄 That saves us a lot of time. We'll take a look and try to get this fixed promptly. Thank you!

@david0178418
Copy link
Author

Glad to hear it helped! I'd have submitted a pr myself if I had more context. Glad that this investigation will save you ask some time.

@schmidt-sebastian
Copy link
Contributor

schmidt-sebastian commented Sep 28, 2019

@david0178418 I'll get this fixed ASAP. In the meantime, if you call DocumentSnapshot.data() first, you should not hit the problematic codepath in subsequent calls to DocumentSnapshot.get().

Update: The codepath seems to only be hit during internal Query processing. The only workaround might be the dummy field you suggested.

@firebase firebase locked and limited conversation to collaborators Nov 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants