microsoft / react-native-code-push

React Native module for CodePush
http://appcenter.ms
Other
8.99k stars 1.48k forks source link

An error occurred while executing doInBackground(), Caused by java.lang.NullPointerException com.microsoft.codepush.react.FileUtils.copyDirectoryContents #2087

Closed natioskar closed 4 months ago

natioskar commented 3 years ago

Steps to Reproduce

I wasn't able to reproduce it myself due to lack of this kind of device, but according to the Crashlytics & Sentry stack trace its only happening on Huawei P30 lite right after the code push update check (with no new pending updates)

Expected Behavior

Just normal update check and continue app loading, with the result of no new update

Actual Behavior

App crashed with the following -

Fatal Exception: java.lang.RuntimeException
An error occurred while executing doInBackground()
    android.os.AsyncTask$4.done (AsyncTask.java:399)
    java.lang.Thread.run (Thread.java:929)
java.io.File.<init> (File.java:283)
com.microsoft.codepush.react.FileUtils.copyDirectoryContents (FileUtils.java:19)
com.microsoft.codepush.react.CodePushUpdateUtils.copyNecessaryFilesFromCurrentPackage (CodePushUpdateUtils.java:100)
com.microsoft.codepush.react.CodePushUpdateManager.downloadPackage (CodePushUpdateManager.java:242)
com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground (CodePushNativeModule.java:290)
com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground (CodePushNativeModule.java:284)
android.os.AsyncTask$3.call (AsyncTask.java:378)
java.util.concurrent.FutureTask.run (FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
java.lang.Thread.run (Thread.java:929)

Reproducible Demo

I don't have a reproducible Demo, but the way I use code push -

CodePush({
  checkFrequency: CodePush.CheckFrequency.ON_APP_RESUME,
  installMode: CodePush.InstallMode.ON_NEXT_RESUME,
})

Environment

Sorry for the lack of reproducible demo and more specific steps, this only started when we rolled out to production

tom-sherman commented 3 years ago

We received the same error in Bugsnag, on a Samsung Galaxy A5(2017) (SM-A520F) on Android 8.0.0

java.lang.RuntimeException: An error occurred while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:353)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
        at java.util.concurrent.FutureTask.run(FutureTask.java:271)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at java.lang.Thread.run(Thread.java:764)

Caused by: java.lang.NullPointerException
        at java.io.File.<init>(File.java:282)
        at com.microsoft.codepush.react.FileUtils.copyDirectoryContents(FileUtils.java:19)
        at com.microsoft.codepush.react.CodePushUpdateUtils.copyNecessaryFilesFromCurrentPackage(CodePushUpdateUtils.java:100)
        at com.microsoft.codepush.react.CodePushUpdateManager.downloadPackage(CodePushUpdateManager.java:228)
        at com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground(CodePushNativeModule.java:290)
        at com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground(CodePushNativeModule.java:284)
        at android.os.AsyncTask$2.call(AsyncTask.java:333)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at java.lang.Thread.run(Thread.java:764)
rodperottoni commented 3 years ago

Seems to be happening for me as well. 2 isolated events in devices from different manufacturers. Same stack trace as posted above.

Screen Shot 2021-05-11 at 3 59 38 pm
HernanAlbertario commented 3 years ago

We are receiving the same error in Crashlytics for different devices (Samsung, Motorola, Xiaomi, LGE) on Android 8, 9, 10 and 11.

Fatal Exception: java.lang.RuntimeException An error occurred while executing doInBackground() android.os.AsyncTask$4.done (AsyncTask.java:399) java.util.concurrent.FutureTask.finishCompletion (FutureTask.java:383) java.util.concurrent.FutureTask.setException (FutureTask.java:252) java.util.concurrent.FutureTask.run (FutureTask.java:271) java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167) java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641) java.lang.Thread.run (Thread.java:919)

Exception java.io.File.<init> (File.java:283) com.microsoft.codepush.react.FileUtils.copyDirectoryContents (FileUtils.java:19) com.microsoft.codepush.react.CodePushUpdateUtils.copyNecessaryFilesFromCurrentPackage (CodePushUpdateUtils.java:100) com.microsoft.codepush.react.CodePushUpdateManager.downloadPackage (CodePushUpdateManager.java:228) com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground (CodePushNativeModule.java:217) com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground (CodePushNativeModule.java:211)

christophemenager commented 3 years ago

I have the exact same error, for those devices at the moment image

natioskar commented 3 years ago

Update (12/6) Its been a month now, and the issue is not recreating for me (but still no answer from Microsoft guys).. can I assume is was it was a single case? is it still happening to you guys?

tom-sherman commented 3 years ago

Same here, happened twice on the 10th of May and then never again...

HernanAlbertario commented 3 years ago

Same here, the last time it happened was on 12th of May.

ted-nz commented 3 years ago

Just had this issue reported from Sentry, occurred Aug 7, 2021 1:22:58 AM UTC. Identical stack trace as previous comments, affected device was Samsung SM-T395, Android 9.

Same as original author, there would have been NO update available.

nikhilk1993 commented 3 years ago

Getting this error as well..any updates on this?

ghost commented 2 years ago

This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs within 15 days of this comment.

tom-sherman commented 2 years ago

This is still happening for us, albeit very infrequently.

simonchengbbyca commented 2 years ago
We mitigated the issue by patching FileUtils.java which is located in 
node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/FileUtils.java

@geof90 @LittleXianyu @andreidubov Please include the following code in the code base or figure out the root cause of the issue.

[Do this after npm ci or install]

try {
    sourceDir = new File(sourceDirectoryPath);
    destDir = new File(destinationDirectoryPath);
} catch (NullPointerException e) {
    throw new CodePushUnknownException("Error creating directories", e);
}

https://github.com/microsoft/react-native-code-push/blob/3f6219cca18b2aced4381935ca00a08cc54e3a13/android/app/src/main/java/com/microsoft/codepush/react/FileUtils.java#L19

jamninetyfive commented 2 years ago

java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$4.done(AsyncTask.java:415) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:920) Caused by: java.lang.NullPointerException at java.io.File.(File.java:323) at com.microsoft.codepush.react.FileUtils.moveFile(FileUtils.java:105) at com.microsoft.codepush.react.CodePushUpdateManager.downloadPackage(CodePushUpdateManager.java:303) at com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground(CodePushNativeModule.java:290) at com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground(CodePushNativeModule.java:284) at android.os.AsyncTask$3.call(AsyncTask.java:394) at java.util.concurrent.FutureTask.run(FutureTask.java:266)

"react-native": "0.66.4", "react-native-code-push": "^7.0.4",

manish-patwari commented 2 years ago

Any update on this issue ? We are also facing the same. This happened once and not repeated for the users.

Screenshot 2022-06-06 at 1 47 07 PM Screenshot 2022-06-06 at 1 45 44 PM

Minishlink commented 2 years ago

This issue popped up for the first time 2 days ago (our app is ~2 years old) after an OTA update.

image image

A corrupted download of the zip file due to network issues on microsoft servers?

HimanshuNarang commented 9 months ago

Facing the same issue, any fix?

DmitriyKirakosyan commented 5 months ago

Is anyone still facing this issue? If so, could you try the patch from this pull request and see if it helps?

DmitriyKirakosyan commented 4 months ago

Closing due to inactivity.

devphilipcesar commented 1 month ago

it's 2024 and the issue still happening on "react-native-code-push": "~8.3.1"

image

image

It's not a good reason to close an issue due to inactivity when there are questions left unanswered :(