From 6b31527bb3bb73195c359ac6fc87bfed850fcaf5 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 23 Sep 2026 14:38:32 +0200 Subject: [PATCH] fix(android): stop a failed download from crashing the app react-native-fs rejects a failed transfer with a null error code, and React Native's Kotlin Promise.reject throws on one. Thrown from the download thread, that killed the app whenever a download failed: a dropped connection, no network at the start, a read timeout, or a stopDownload. Reject with EUNSPECIFIED instead, so the failure reaches the retry logic and the "Download failed" alert. Verified on a Pixel 9a (Android 17). Switching on airplane mode during the pack download crashed the app before this change. With it, the app shows "Download failed" after three attempts, and the next update downloads and installs the pack. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- patches/react-native-fs+2.20.0.patch | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/patches/react-native-fs+2.20.0.patch b/patches/react-native-fs+2.20.0.patch index 39ba1eb08..a3e674926 100644 --- a/patches/react-native-fs+2.20.0.patch +++ b/patches/react-native-fs+2.20.0.patch @@ -23,7 +23,7 @@ index 5ddd941..058d47e 100644 }; diff --git a/node_modules/react-native-fs/android/src/main/java/com/rnfs/RNFSManager.java b/node_modules/react-native-fs/android/src/main/java/com/rnfs/RNFSManager.java -index 351ac06..5aa4ea4 100644 +index 351ac06..b7f5be0 100644 --- a/node_modules/react-native-fs/android/src/main/java/com/rnfs/RNFSManager.java +++ b/node_modules/react-native-fs/android/src/main/java/com/rnfs/RNFSManager.java @@ -638,6 +638,7 @@ public class RNFSManager extends ReactContextBaseJavaModule { @@ -34,6 +34,17 @@ index 351ac06..5aa4ea4 100644 promise.resolve(statMap); } catch (Exception ex) { +@@ -975,7 +976,9 @@ public class RNFSManager extends ReactContextBaseJavaModule { + return; + } + +- promise.reject(null, ex.getMessage()); ++ // React Native's Kotlin Promise.reject throws on a null code; thrown from the download ++ // thread, that crashed the app whenever a download failed. ++ promise.reject("EUNSPECIFIED", ex.getMessage(), ex); + } + + private void rejectFileNotFound(Promise promise, String filepath) { diff --git a/node_modules/react-native-fs/index.d.ts b/node_modules/react-native-fs/index.d.ts index da3fa7d..dc6f060 100644 --- a/node_modules/react-native-fs/index.d.ts