fix(android): stop a failed download from crashing the app - #44
Merged
JasonWildMe merged 1 commit intoSep 23, 2026
Merged
JasonWildMe merged 1 commit into
JasonWildMe merged 1 commit into
Conversation
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>
This was referenced Sep 23, 2026
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Any failed download crashes the Android app. In
RNFSManager.reject, react-native-fs 2.20.0 rejects failed operations with a null error code:promise.reject(null, ex.getMessage()). React Native's KotlinPromise.reject(code: String, message: String?)does not accept a nullcode, so the call throws:It is thrown on the download thread, which kills the process. It fires on every generic failure:
stopDownload, which fix(ios): make sign-in work, and stop failures happening in silence #42's inactivity watchdog callsOther react-native-fs methods that reach the same helper with a generic exception crash the same way. The current Android field build uses the same library versions, so an interrupted model or pack download there most likely crashes too.
The fix is one line in the existing react-native-fs patch: reject with
EUNSPECIFIEDand pass the exception. The failure then reachesfileDownloadService's retry logic and the "Download failed" alert.Type of Change
Screenshots / Screen Recordings
Android
Checklist
General
Testing
npm test)Tested on a Pixel 9a (Android 17), using a debug build with this patch. The build was made from #45's branch, which contains the same react-native-fs sources. I switched on airplane mode at 93% of the pack download:
FATAL EXCEPTION … RNFSManager.reject, and the app closed.The patch applies cleanly on a fresh
npm ci(patch-package ✔). No JS changed. The iOS side of the patch is unchanged, so iOS is not affected. No automated test was added, since this is a third-party native module; the device run above is the verification.CI:
android-build,lintandtestfail in the Setup Android SDK step, where the macOS runner'scmdline-tools16.0 stops on unaccepted SDK licences. That is the same failure as on #42 and unrelated to this change;typecheckpasses.Performance & Models
Security
Related Issues
Found while testing #45, which is stacked on #42.
Additional Notes