-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
com.microsoft.codepush.react.CodePushMalformedDataException Unable to parse contents of [..]/codepush.json #1149
Comments
Hi @maxkomarychev, thanks for reaching us.
Absolutely agreed, to have good UX we definitely should not crash an app while installing broken CodePush update. Currently, we are actively working on CodePush native SDKs (both Android and Apple) migration to the App Center native SDKs, while migrating we are going to fix such kind of problems in addition to general rollbacks enhancement (add an ability to see the reason of rollbacks). The migration process will take some time and when we have it finished - you'll be able to use appcenter-codepush service from the https://github.com/Microsoft/AppCenter-SDK-React-Native/ with all the improvements I've listed above. Please also let me know if you see any other issues or have any questions. |
thanks! do you have any ETA/roadmap on when those new SDKs will be available? |
We have this issue reported in our app too both in Sentry and Crashlytics, and likewise haven't been able to reproduce it ourselves. Our current 7-day metrics for this crash indicate that out of our about 2k weekly active users, 40 users see this crash every week (they're not the same week after week BTW), so roughly 2% of our userbase is affected. It is not a major issue for us, but it is also not rare enough that it doesn't produce some discomfort. We don't know what the root cause is, but are considering working on a fix to at least prevent CodePush from crashing the app when this happens. |
Seeing this on a production app as well. As suggested before, CodePush should probably fallback to the original bundle rather than crashing. |
Im getting this as well. please fix! |
Also happening here, however it seems to only occur in a specific device (Twist S520).
|
We also see this on Samsung Galaxy S9 and Sony Xperia X compact |
@yuri-kulikov any update on this issue...approximately 5% of users face this issue |
This really bugs people here, which make CodePush is unusable on any production environment, yet the migration to AppCenter already took one year and we haven't seen any glance of a trace of CodePush being migrated, looks like CodePush has been overlooked for a while. Anyway, we've made a workaround for this unrecoverable fatal error here, the whole idea is to mimic the behavior of In your MainApplication.java or whever you manage ReactNativeInstance, @Override
protected List<ReactPackage> getPackages() {
CodePush codePush;
try {
codePush = new CodePush(BuildConfig.CODEPUSH_KEY, getApplicationContext(), BuildConfig.DEBUG);
} catch (Exception e) {
// Reset code push update files when update files corrupted.
// The following code is a mimic of CodePush.clearUpdates()
// Since we already has exception in CodePush constructor,
// we breakdown the constructor here and clear all code push
// related files step by step without read the corrupted file itself.
Context mContext = getApplicationContext();
CodePushUpdateManager mUpdateManager = new CodePushUpdateManager(mContext.getFilesDir().getAbsolutePath());
SettingsManager mSettingsManager = new SettingsManager(mContext);
mUpdateManager.clearUpdates();
mSettingsManager.removeFailedUpdates();
mSettingsManager.removePendingUpdate();
// After code push update files being removed, we can build a new code push instance safely
codePush = new CodePush(BuildConfig.CODEPUSH_KEY, getApplicationContext(), BuildConfig.DEBUG);
}
return Arrays.<ReactPackage>asList(
codePush
//...your other react native packages
);
} If you are a careful person, you might need a way to reproduce this exception, the easiest way to do this is upload a 0 bytes |
Hi @eggli, We'll try to reproduce it as you recommended and try to create a workaround in our package until we find out why |
@eggli thanks for the workaround. We will try this solution |
I've checked codes that read/writes Yet personally I've reproduced this empty file situation sometimes with this method, but it's not 100% reproducible. |
@eggli, thanks for sharing this information with us. I tried to reproduce this bug but wasn't lucky enough. Work on a fix is in progress. |
Hi everyone! I'll close the issue for now, but feel free to ask any questions or reopen this issue if needed! |
Still seeing this in production on version in 6.4.1:
|
Still seeing this in production on version Fatal Exception: com.microsoft.codepush.react.d
Unable to parse contents of /data/user/0/in.example.tech/files/CodePush/codepush.json, the file may be corrupted.
com.microsoft.codepush.react.CodePushUtils.getJsonObjectFromFile
Fatal Exception: com.microsoft.codepush.react.d: Unable to parse contents of /data/user/0/in.example.tech/files/CodePush/codepush.json, the file may be corrupted.
at com.microsoft.codepush.react.CodePushUtils.getJsonObjectFromFile(CodePushUtils.java:200)
at com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackageInfo(CodePushUpdateManager.java:59)
at com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackageHash(CodePushUpdateManager.java:109)
at com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackage(CodePushUpdateManager.java:119)
at com.microsoft.codepush.react.CodePush.initializeUpdateAfterRestart(CodePush.java:298)
at com.microsoft.codepush.react.CodePush.<init>(CodePush.java:88)
at in.example.tech.di.modules.ReactNativeModule$getReactNativeHost$1.getPackages(ReactNativeModule.java:70)
at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:77)
at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:39)
at tech.library.react.ReactUtils.createReactContextInBackground(ReactUtils.java:42)
at tech.library.react.ReactUtils$createReactContextInBackground$1.invokeSuspend(ReactUtils.java:11)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(BaseContinuationImpl.java:33)
at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(ScopeCoroutine.java:33)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.java:102)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(BaseContinuationImpl.java:46)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.java:106)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6861)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by org.json.JSONException: End of input at character 0 of
at org.json.JSONTokener.syntaxError(JSONTokener.java:449)
at org.json.JSONTokener.nextValue(JSONTokener.java:97)
at org.json.JSONObject.<init>(JSONObject.java:159)
at org.json.JSONObject.<init>(JSONObject.java:176)
at com.microsoft.codepush.react.CodePushUtils.getJsonObjectFromFile(CodePushUtils.java:197)
at com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackageInfo(CodePushUpdateManager.java:59)
at com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackageHash(CodePushUpdateManager.java:109)
at com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackage(CodePushUpdateManager.java:119)
at com.microsoft.codepush.react.CodePush.initializeUpdateAfterRestart(CodePush.java:298)
at com.microsoft.codepush.react.CodePush.<init>(CodePush.java:88)
at in.example.tech.di.modules.ReactNativeModule$getReactNativeHost$1.getPackages(ReactNativeModule.java:70)
at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:77)
at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:39)
at example.library.react.ReactUtils.createReactContextInBackground(ReactUtils.java:42)
at example.library.react.ReactUtils$createReactContextInBackground$1.invokeSuspend(ReactUtils.java:11)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(BaseContinuationImpl.java:33)
at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(ScopeCoroutine.java:33)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.java:102)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(BaseContinuationImpl.java:46)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.java:106)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6861)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873) |
this issue still exists, currently we are running on |
still there on |
v8.2.1 also.. |
This issue was fixed in v8.2.2 (#2668). |
Hi,
this is the crash report I've got from crash-analytics service. I wasn't able to reproduce it myself however whatever happens the codepush should not crash, it should safely fallback to original bundle if error happened during it's initialization.
Expected Behavior
CodePush should not crash the app. It should safely fallback to original bundle.
Actual Behavior
App crashes.
Reproducible Demo
I do have this
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
line inbuild.gradle
Environment
Happened dozen of times on release build on physical device.
The text was updated successfully, but these errors were encountered: