Skip to content

Firestore blows up on GET {source: "cache"} if document exists in cache #1632

Closed
@scottmas

Description

Issue

When the data gets in a certain state (I don't know how), when I request a document with {source: 'cache'} that doesn't exist in the cache, the library blows up with the following error. While I am using React Native, the RN Firebase folks have triaged the issue and are relatively confident it's not on their end.

Error follows:

'NSInvalidArgumentException', reason: '-[FSTDeletedDocument data]: unrecognized selector sent to instance 0x600000244230'
*** First throw call stack:
(
	0   CoreFoundation                      0x0000000110da91e6 __exceptionPreprocess + 294
	1   libobjc.A.dylib                     0x000000010f695031 objc_exception_throw + 48
	2   CoreFoundation                      0x0000000110e2a784 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
	3   CoreFoundation                      0x0000000110d2b898 ___forwarding___ + 1432
	4   CoreFoundation                      0x0000000110d2b278 _CF_forwarding_prep_0 + 120
	5   OllieApp                            0x000000010c2783de -[FIRDocumentSnapshot dataWithServerTimestampBehavior:] + 238
	6   OllieApp                            0x000000010c2782df -[FIRDocumentSnapshot data] + 47
	7   OllieApp                            0x000000010ca82911 +[RNFirebaseFirestoreDocumentReference snapshotToDictionary:] + 305
	8   OllieApp                            0x000000010ca816b7 __62-[RNFirebaseFirestoreDocumentReference get:resolver:rejecter:]_block_invoke + 151
	9   OllieApp                            0x000000010c2d3883 __59-[FSTFirestoreClient getDocumentFromLocalCache:completion:]_block_invoke + 499
	10  OllieApp                            0x000000010c2b3504 _ZZ34-[FSTDispatchQueue dispatchAsync:]ENK3$_1clEv + 36
	11  OllieApp                            0x000000010c2b34cd _ZNSt3__128__invoke_void_return_wrapperIvE6__callIJRZ34-[FSTDispatchQueue dispatchAsync:]E3$_1EEEvDpOT_ + 45
	12  OllieApp                            0x000000010c2b3299 _ZNSt3__110__function6__funcIZ34-[FSTDispatchQueue dispatchAsync:]E3$_1NS_9allocatorIS2_EEFvvEEclEv + 41
	13  OllieApp                            0x000000010c2b0c8b _ZNKSt3__18functionIFvvEEclEv + 123
	14  OllieApp                            0x000000010c24d27c _ZN8firebase9firestore4util10AsyncQueue15ExecuteBlockingERKNSt3__18functionIFvvEEE + 476
	15  OllieApp                            0x000000010c24fc07 _ZZN8firebase9firestore4util10AsyncQueue4WrapERKNSt3__18functionIFvvEEEENK3$_0clEv + 39
	16  OllieApp                            0x000000010c24fbcd _ZNSt3__128__invoke_void_return_wrapperIvE6__callIJRZN8firebase9firestore4util10AsyncQueue4WrapERKNS_8functionIFvvEEEE3$_0EEEvDpOT_ + 45
	17  OllieApp                            0x000000010c24f989 _ZNSt3__110__function6__funcIZN8firebase9firestore4util10AsyncQueue4WrapERKNS_8functionIFvvEEEE3$_0NS_9allocatorISB_EES7_EclEv + 41
	18  OllieApp                            0x000000010c2b0c8b _ZNKSt3__18functionIFvvEEclEv + 123
	19  OllieApp                            0x000000010c25db01 _ZZN8firebase9firestore4util8internal13DispatchAsyncEPU28objcproto17OS_dispatch_queue8NSObjectONSt3__18functionIFvvEEEENK3$_0clEPv + 33
	20  OllieApp                            0x000000010c25dad8 _ZZN8firebase9firestore4util8internal13DispatchAsyncEPU28objcproto17OS_dispatch_queue8NSObjectONSt3__18functionIFvvEEEEN3$_08__invokeEPv + 24
	21  libdispatch.dylib                   0x0000000114bf87ec _dispatch_client_callout + 8
	22  libdispatch.dylib                   0x0000000114c00be5 _dispatch_queue_serial_drain + 1305
	23  libdispatch.dylib                   0x0000000114c014fa _dispatch_queue_invoke + 328
	24  libdispatch.dylib                   0x0000000114bfd344 _dispatch_queue_override_invoke + 726
	25  libdispatch.dylib                   0x0000000114c0436c _dispatch_root_queue_drain + 664
	26  libdispatch.dylib                   0x0000000114c04076 _dispatch_worker_thread3 + 132
	27  libsystem_pthread.dylib             0x000000011511d1ca _pthread_wqthread + 1387
	28  libsystem_pthread.dylib             0x000000011511cc4d start_wqthread + 13
)

The firestore debug logs are not helpful:

Committing transaction: <LevelDbTransaction Start MutationQueue: 0 changes (0 bytes):>
Committing transaction: <LevelDbTransaction NextMutationBatchAfterBatchID: 0 changes (0 bytes):>
Committing transaction: <LevelDbTransaction ReadDocument: 0 changes (0 bytes):>
-[FSTDeletedDocument data]: unrecognized selector sent to instance 0x60c00005fd40
...(The above error follows)

Steps to reproduce:

  1. Get your data in a corrupted state. Not sure how.
  2. Run the following code:
await firebase.firestore()
    .collection('my-collection')
    .doc('some-doc-id')
    .get({ source: 'server' });

await firebase.firestore()
    .collection('my-collection')
    .doc('some-doc-id')
    .get({ source: 'cache' })

//Native exception thrown...

Note: After nuking local data, the error goes away and the request happens just fine.

Environment

IOS
macOS Sierra
RN 54
RN FIrebase 4.3.5
Firestore 5.4.1 in
Not using Typescript.

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions