Android: don't let download/install failures escape as hung promises - #33
Merged
Conversation
downloadUpdate and installUpdate run inside AsyncTask.doInBackground, but their catch clauses only listed a subset of the exception types the code underneath can actually throw (e.g. downloadUpdate didn't catch CodePushMalformedDataException, which downloadPackage throws for a malformed download URL). Any exception type not explicitly caught escapes doInBackground uncaught, and the JS promise never settles - no resolve, no reject, just a permanent hang with nothing in logcat tying it to a cause. Add the missing CodePushMalformedDataException catch, plus a final catch (Exception e) safety net in both methods so every failure path - including ones not yet enumerated - ends in a rejected promise instead of an uncaught background-thread exception.
ofalvai
force-pushed
the
push-pmsqzktxxwqw
branch
from
August 17, 2026 09:18
83ea2db to
d4e81e3
Compare
There was a problem hiding this comment.
Pull request overview
Ensures Android download/install failures reject JavaScript promises instead of hanging.
Changes:
- Handles malformed-data exceptions explicitly.
- Adds fallback exception handling and logging.
Suppressed comments (1)
android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java:409
- The safety-net catch cannot handle exceptions thrown by the preceding
CodePushInvalidUpdateExceptionhandler. In particular,saveFailedUpdatethrowsCodePushMalformedDataExceptionwhen the stored failed-update JSON is corrupt (SettingsManager.java:105-110), so that concrete path still escapesdoInBackgroundand leaves the promise unsettled. Guard the bookkeeping separately so the original download error is always rejected.
} catch (Exception e) {
// Safety net: make sure a download failure always rejects the JS promise
// instead of escaping this background task uncaught, which would leave
// the promise hanging forever with no error and no log tying it to a cause.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| mSettingsManager.saveFailedUpdate(CodePushUtils.convertReadableToJsonObject(updatePackage)); | ||
| promise.reject(e); | ||
| } catch (IOException | CodePushUnknownException e) { | ||
| } catch (IOException | CodePushUnknownException | CodePushMalformedDataException e) { |
Collaborator
Author
There was a problem hiding this comment.
IMHO this is an overkill, given how slow and unrealiable our current E2E tests are, and that we are planning to add unit tests in the future.
ofalvai
marked this pull request as ready for review
August 17, 2026 09:19
sajtizsolt
approved these changes
Aug 17, 2026
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.
Part of a list of quick tactical logging fixes.
downloadUpdateandinstallUpdaterun insideAsyncTask.doInBackground, but their catch clauses only listed a subset of the exception types the code underneath can actually throw. Any exception type not explicitly caught escapesdoInBackgrounduncaught, and the JS promise never settles: no resolve, no reject, just a permanent hang with nothing in logcat tying it to a cause.Add the missing
CodePushMalformedDataExceptioncatch, plus a finalcatch (Exception e)safety net in both methods so every failure path - including ones not yet enumerated - ends in a rejected promise instead of an uncaught background-thread exception.