firebase-kotlin-sdk icon indicating copy to clipboard operation
firebase-kotlin-sdk copied to clipboard

iOS crash due to Kotlin errors not propagating

Open akaffenberger opened this issue 4 years ago • 2 comments
trafficstars

While in offline mode, firestore throws an error about lack of connection, which is expected. However this is then made into an exception that crashes the app:

2021-03-12 20:11:58.504712-0500 App Debug[5814:1500195] 7.3.0 - [Firebase/Firestore][I-FST000001] Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.
 This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
Exception doesn't match @Throws-specified class list and thus isn't propagated from Kotlin to Objective-C/Swift as NSError.
It is considered unexpected and unhandled instead. Program will be terminated.
Uncaught Kotlin exception: dev.gitlive.firebase.firestore.FirebaseFirestoreException: Error Domain=FIRFirestoreErrorDomain Code=14 "Failed to get document because the client is offline." UserInfo={NSLocalizedDescription=Failed to get document because the client is offline.}
    at 0   App Debug                      0x00000001025fce54 kfun:kotlin.Throwable#<init>(kotlin.String?){} + 96
    at 1   App Debug                      0x00000001025f593c kfun:kotlin.Exception#<init>(kotlin.String?){} + 92
    at 2   App Debug                      0x00000001027d2110 kfun:dev.gitlive.firebase.FirebaseException#<init>(kotlin.String){} + 92
    at 3   App Debug                      0x00000001028095d8 kfun:dev.gitlive.firebase.firestore.FirebaseFirestoreException#<init>(kotlin.String;dev.gitlive.firebase.firestore.FirestoreExceptionCode){} + 112
    at 4   App Debug                      0x0000000102809b30 kfun:dev.gitlive.firebase.firestore#[email protected](){}dev.gitlive.firebase.firestore.FirebaseFirestoreException + 1268
    at 5   App Debug                      0x00000001028028d8 kfun:dev.gitlive.firebase.firestore.DocumentReference.get$<anonymous>_2_4#internal + 308
    at 6   App Debug                      0x000000010280445c kfun:dev.gitlive.firebase.firestore.DocumentReference.$get$<anonymous>_2_4$FUNCTION_REFERENCE$88.invoke#internal + 124
    at 7   App Debug                      0x00000001028044f8 kfun:dev.gitlive.firebase.firestore.DocumentReference.$get$<anonymous>_2_4$FUNCTION_REFERENCE$88.$<bridge-UNNNN>invoke(-1:0;-1:1){}#internal + 124
    at 8   App Debug                      0x0000000102810c9c _6465762e6769746c6976653a66697265626173652d6669726573746f7265_knbridge73 + 292
    at 9   App Debug                      0x00000001029a5e6c _ZZ50-[FIRDocumentReference wrapDocumentSnapshotBlock:]EN9Converter7OnEventEN8firebase9firestore4util8StatusOrINS1_3api16DocumentSnapshotEEE + 72
    at 10  App Debug                      0x0000000102988708 _ZZN8firebase9firestore3api17DocumentReference11GetDocumentENS1_6SourceEONSt3__110unique_ptrINS0_4core13EventListenerINS1_16DocumentSnapshotEEENS4_14default_deleteIS9_EEEEEN10ListenOnce7OnEventENS0_4util8StatusOrIS8_EE + 336
    at 11  App Debug                      0x0000000102989498 _ZZN8firebase9firestore3api17DocumentReference19AddSnapshotListenerENS0_4core13ListenOptionsEONSt3__110unique_ptrINS3_13EventListenerINS1_16DocumentSnapshotEEENS5_14default_deleteIS9_EEEEEN9Converter7OnEventENS0_4util8StatusOrINS3_12ViewSnapshotEEE + 788
    at 12  App Debug                      0x00000001029d1550 _ZNSt3__128__invoke_void_return_wrapperIvE6__callIJRZN8firebase9firestore4core18AsyncEventListenerINS5_12ViewSnapshotEE7OnEventENS4_4util8StatusOrIS7_EEEUlvE_EEEvDpOT_ + 104
    at 13  App Debug                      0x0000000102a70124 _ZN8firebase9firestore4util4Task17ExecuteAndReleaseEv + 184
    at 14  libdispatch.dylib                   0x000000010967d6c0 _dispatch_client_callout + 20
    at 15  libdispatch.dylib                   0x000000010968cf34 _dispatch_main_queue_callback_4CF + 1000
    at 16  CoreFoundation                      0x00000001836fd11c 727F2644-EB4E-3D57-BC2E-E6803BA92366 + 659740
    at 17  CoreFoundation                      0x00000001836f7120 727F2644-EB4E-3D57-BC2E-E6803BA92366 + 635168
    at 18  CoreFoundation                      0x00000001836f621c CFRunLoopRunSpecific + 600
    at 19  GraphicsServices                    0x000000019b2c2784 GSEventRunModal + 164
    at 20  UIKitCore                           0x0000000186136ee8 8518EAE3-832B-3FF0-9FA5-9DBE3041F26C + 12357352
    at 21  UIKitCore                           0x000000018613c75c UIApplicationMain + 168
    at 22  App Debug                      0x0000000100465a7c main + 88

This isn't ideal because we want to allow offline mode in our app. Ideally we would like a way to catch that error and handle it without a crash.

akaffenberger avatar Mar 13 '21 01:03 akaffenberger

A test need to be added for this once the ios test are running

nbransby avatar May 13 '21 22:05 nbransby

ios tests are running now so would be great if you could send a PR with a failing test for this

nbransby avatar Apr 06 '22 18:04 nbransby