I originally posted an issue on Github here (https://github.com/expo/expo/issues/370), but I’ve found more information on this recently that’s clarified what’s really going on and made the issue a bit more urgent for me (now it affects an app that is about to go into production, it’s not just a test environment thing). So, looking for any advice on possible workarounds, for sure!
On Android, I subscribe to the update listener, and then trigger a reload when a new version is detected after restarting the app. My app has a login screen, and a session cookie is set by the response when a user successfully logs in, so all future requests have the cookie. My app also has images secured behind the session ID that are displayed with the stock Image component (think of a chat feed with text and images).
After I publish an update to the JavaScript bundles, I close the Android app, restart it, and the update listener picks up that there’s an update and runs my callback, which shows an alert and then reloads the experience. When I reload the experiences, any new images that were not already cached by the app do not download. When I put them through an HTTP sniffer, a) the cookie is not on the image requests, and b) the image requests appear to be using an entirely different HTTP client (Android/ davlik, not okhttp).
If I close and restart the app again, all is fine again. The images appear, and the network sniffer reports that cookies are attached to the image requests and they’re back to going through okhttp.
Here’s an image request header pre-reload / after closing the app after it reloads and images don’t appear (aka, “the good one”):
GET /4/message/image/497 HTTP/1.1
Host ...
Connection Keep-Alive
Accept-Encoding gzip
Cookie session=...
User-Agent okhttp/3.6.0
And here’s the image request header after the reload (aka, “the bad one”):
GET /4/message/image/498 HTTP/1.1
User-Agent Dalvik/2.1.0 (Linux; U; Android 6.0.1; Moto G Play Build/MPI24.241-2.35-1.5)
Host ...
Connection Keep-Alive
Accept-Encoding gzip
This is all on Expo 22 (haven’t been able to upgrade to 23 due to a breaking change for me, planning on upgrading to 24 though). This has been around since at least Expo 19 in some form.
Here’s my check for update code:
// handle updates to Expo JS bundle for Android
const updateListener = Util.addNewVersionListenerExperimental(() => {
Alert.alert(
'An Update is Available',
'The app will now reload so you can take advantage of the latest improvements.',
[
// { text: 'Don\'t reload right now', onPress: () => {}, style: 'cancel' },
{
text: 'Reload and update',
onPress: () => {
Util.reload();
},
},
],
{ cancelable: false }
);
});
Any ideas on any workarounds for this? Is there another Image component I can use? Am I reloading wrong?
Thanks!