Updates.reloadAsync not updating?

I’ve just pushed an EAS Update to our production channel (we’re using Expo 47) and the app correctly identifies that there’s a new update, i.e. Updates.checkForUpdateAsync().isAvailable now return true. But it then doesn’t actually install the update. So it goes round in a circle offering to update, seeming to do it and then asking again.

Given that this is in our deployed production app, I need to find a fix. Either cancel the update (is there any way to do this in expo.dev?) or find a way to get the app to install the update.

We’re relatively new to using EAS Updates, but we’ve successfully pushed one update to production a few weeks ago, and we’ve tested this on our staging builds and it’s worked OK.

I’ve looked in the adb logs but can’t see any errors.

How can I fix this?

SDK: 47
Platform: both iOS and Android

I found the problem: we had added expo-av to our package.json. This presumably has some native part and thus the new update wasn’t compatible with the old binary in production.

Unfortunately, there’s no warning to tell you that an update is incompatible with a binary. What’s worse is that when the app tries to update and fails, then it reverts back to the JavaScript originally bundled when the app was submitted to the Play and App Stores. So by unsuccessly pushing an incompatible update, we not only got into the cycle of it always prompting to update, but also the app regressed to a much earlier version.

Luckily there’s a work around. If this happens to you, you can execute yarn eas channel:edit production --branch <name of latest compatible branch>. That way you can at least go back to your latest compatible branch, your app will then load this update and stop trying to upload anything else. I hope this helps.

What would be really useful, is some way of checking if an update is compatible :slight_smile:

2 Likes

SDK 48
“expo-updates”: “~0.16.3”,

I’m also having issues with expo-updates. I followed this guide. I made sure that expo-updates is configured into my eas.json. Then I used EAS to create a new app store build. I upload this build to the app store and load it into TestFlight onto my device.

Then I change some colors in my code and run eas update --branch production --message 'Updating the app'.

I do not see the changes.

Do I need to to set anything else up that isn’t in the docs so that the app will automatically update? Or do I need to push a new version to the app store? I don’t mind pushing new versions into the app store but I want to notify the users that they need to download a new version. Not sure how to do that :thinking:

Do i need to do this still:

import * as Updates from 'expo-updates';

export default async () => {
  try {
    const update = await Updates.checkForUpdateAsync();
    if (update.isAvailable) {
      await Updates.fetchUpdateAsync();
      // Show a dialog to the user asking if they want to update
      await Updates.reloadAsync();
    }
  } catch (e) {
    // Handle error
  }
};

HI @adriaanbalt,

Have you changed your package.json since you first built your production channel app?

You can test out the update mechanism without touching your production app.

First update eas.json and add a staging profile. This is what we have:

    "staging": {
      "channel": "staging",
      "distribution": "internal",
      "android": {
        "buildType": "apk"
      }
    },

You can then create test apps that you can install using:

yarn eas build --platform all --profile staging

Now you can install that on your test devices. Once you have it running, you can then make some changes to your code and then run eas update --branch staging. This should then call your code and update your app.

Actually one of the things that you don’t say is how and when your code (which looks right to me) is called. Unless you are explicitly calling it from somewhere, it won’t check for updates. I call mine whenever the home screen comes to the foreground.

Solution:

Originally, I was not triggering this code but after adding it, and then building and uploading to the appstore, my “Over the air” updates have worked. I call this method in App.tsx:

import * as Updates from 'expo-updates';

export default async () => {
  try {
    const update = await Updates.checkForUpdateAsync();
    if (update.isAvailable) {
      await Updates.fetchUpdateAsync();
      // Show a dialog to the user asking if they want to update
      await Updates.reloadAsync();
    }
  } catch (e) {
    // Handle error
  }
};

You can improve this code as per the comments but adding this bare version fixed the issue for me.

As an aside, these are (part of) my configs:

My app.json:

    "updates": {
      "enabled": true,
      "checkAutomatically": "ON_ERROR_RECOVERY",
      "fallbackToCacheTimeout": 0,
      "url": "https://u.expo.dev/12345"
    },

My eas.json

    "production": {
      "extends": "base",
      "autoIncrement": true,
      "env": {
        "ENVIRONMENT": "production"
      },
      "channel": "production"
    }

There is no mention of the above snippet in this guide.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.