opensrp / fhircore

FHIR Core / OpenSRP 2 is a Kotlin application for delivering offline-capable, mobile-first healthcare project implementations from local community to national and international scale using FHIR and WHO Smart Guidelines on Android.
https://smartregister.org
Apache License 2.0
50 stars 39 forks source link

Error handling with Coroutines #3228

Closed ndegwamartin closed 2 months ago

ndegwamartin commented 2 months ago

Describe the Issue It has been observed that sometimes the app crashes or silently fails without any Logs displayed in std out during development or Sentry for releases. Some investigations pointed to the exceptions thrown within Coroutine scopes somehow 'disappearing' .

We want to troubleshoot further and come up with a better error handling solution in this context.

pld commented 2 months ago

Any thoughts on how to reproduce this?

LZRS commented 2 months ago

We experienced something similar when working on WDF with @Rkareko. In our case, this line seemed to have been the culprit

https://github.com/opensrp/fhircore/blob/main/android/engine/src/main/java/org/smartregister/fhircore/engine/configuration/ConfigurationRegistry.kt#L109

Anytime an error occurred it didn't throw but killed the process

pld commented 2 months ago

oh nice catch! that seems very suspicious can remove that init block? that looks like the only place we call setDefaultUncaughtExceptionHandler