Skip to content

Android: don't let download/install failures escape as hung promises - #33

Merged
ofalvai merged 1 commit into
masterfrom
push-pmsqzktxxwqw
Aug 17, 2026
Merged

Android: don't let download/install failures escape as hung promises#33
ofalvai merged 1 commit into
masterfrom
push-pmsqzktxxwqw

Conversation

@ofalvai

@ofalvai ofalvai commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Part of a list of quick tactical logging fixes.

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. 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.

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
ofalvai force-pushed the push-pmsqzktxxwqw branch from 83ea2db to d4e81e3 Compare August 17, 2026 09:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CodePushInvalidUpdateException handler. In particular, saveFailedUpdate throws CodePushMalformedDataException when the stored failed-update JSON is corrupt (SettingsManager.java:105-110), so that concrete path still escapes doInBackground and 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) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
ofalvai marked this pull request as ready for review August 17, 2026 09:19
@ofalvai
ofalvai merged commit 409db41 into master Aug 17, 2026
5 checks passed
@ofalvai
ofalvai deleted the push-pmsqzktxxwqw branch August 17, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants