Android production build high crash rate

Hi

I ran into this “Unexpected end of script” error in December and did some digging. In my case I was using the managed workflow, but I think this is the same issue regardless.

As far as I know this is caused by incomplete OTA updates. e.g. if the app starts downloading the bundle but is closed before the download finishes then the app will try to load the truncated bundle the next time it starts and will crash with an “Unexpected end of script” error. I was able to reproduce this by installing an APK, publishing an update, and then repeatedly opening and closing the app to try to catch it in the process of downloading the OTA update. At the time I was on wifi with a weak signal which might have helped to reproduce the problem.

See also my comments here:

https://github.com/expo/expo/issues/5839#issuecomment-572296759
https://github.com/expo/expo/issues/5839#issuecomment-572895474

In that first comment I quote a suggested workaround from @charliecruzan (basically doing the OTA updates yourself instead of letting Expo do the automatic OTA update on start.) This seems to have fixed it for me, but my app is not on the Play store and only has a single user at the moment, so I can’t say for certain.

I was later able to force the crash by deliberately truncating a bundle and letting the app do an OTA update with the bad bundle:

$ expo export --public-url https://example.com/blah/
$ rsync -avxz --progress --delete --stats dist/ example.com:/blah/
$ rm -r dist
$ expo ba --public-url https://example.com/blah/android-index.json
$ expo export --public-url https://example.com/blah/
[Manually truncate dist/bundles/android-*.js] 
$ rsync -avxz --progress --delete --stats dist/ example.com:/blah/

So I suggest you try the workaround. It won’t fix a deliberately broken bundle, but it should hopefully avoid issues with partially downloaded bundles during automatic OTA updates.

Also, apparently the Expo team is busy with a rework of the OTA updates system.

1 Like