|
| 1 | +diff --git a/android/src/main/java/expo/modules/updates/errorrecovery/ErrorRecovery.kt b/android/src/main/java/expo/modules/updates/errorrecovery/ErrorRecovery.kt |
| 2 | +index c216e1cfaff3b6c0bcae4f0fd68f02cadac7aabd..702735099c49f811caae7f71ce9291f9f6c7104a 100644 |
| 3 | +--- a/android/src/main/java/expo/modules/updates/errorrecovery/ErrorRecovery.kt |
| 4 | ++++ b/android/src/main/java/expo/modules/updates/errorrecovery/ErrorRecovery.kt |
| 5 | +@@ -29,6 +29,7 @@ class ErrorRecovery( |
| 6 | + internal lateinit var handler: Handler |
| 7 | + |
| 8 | + private var shouldHandleReactInstanceException = false |
| 9 | ++ private var previousBridgelessExceptionHandler: ((Exception) -> Unit)? = null |
| 10 | + |
| 11 | + fun initialize(delegate: ErrorRecoveryDelegate) { |
| 12 | + if (!::handler.isInitialized) { |
| 13 | +@@ -49,6 +50,13 @@ class ErrorRecovery( |
| 14 | + internal fun onReactInstanceException(exception: Exception) { |
| 15 | + if (shouldHandleReactInstanceException) { |
| 16 | + handleException(exception) |
| 17 | ++ } else if (previousBridgelessExceptionHandler != null) { |
| 18 | ++ // PATCHED: Instead of silently ignoring, pass to fallback handler |
| 19 | ++ try { |
| 20 | ++ previousBridgelessExceptionHandler?.invoke(exception) |
| 21 | ++ } catch (e: Exception) { |
| 22 | ++ logger.error("Error in bridgeless exception fallback handler", e, UpdatesErrorCode.Unknown) |
| 23 | ++ } |
| 24 | + } |
| 25 | + } |
| 26 | + |
| 27 | +@@ -92,9 +100,16 @@ class ErrorRecovery( |
| 28 | + |
| 29 | + private fun registerErrorHandler(devSupportManager: DevSupportManager) { |
| 30 | + shouldHandleReactInstanceException = true |
| 31 | ++ // PATCHED: Store the current default uncaught exception handler as fallback |
| 32 | ++ previousBridgelessExceptionHandler = { exception -> |
| 33 | ++ Thread.getDefaultUncaughtExceptionHandler()?.uncaughtException(Thread.currentThread(), exception) |
| 34 | ++ } |
| 35 | + } |
| 36 | + |
| 37 | + private fun unregisterErrorHandler() { |
| 38 | + shouldHandleReactInstanceException = false |
| 39 | ++ // PATCHED: Do NOT clear previousBridgelessExceptionHandler |
| 40 | ++ // Keep it active so crashes after 10s are still passed to the fallback handler |
| 41 | ++ // instead of being silently ignored. This is the core fix for the Bridgeless crash issue. |
| 42 | + } |
| 43 | + } |
0 commit comments