fetchUpdateAsync with new release channels seems not to be working

Hello guys!

I have a question about Updates in Bare Workflow. What I am trying to do is:

  1. Check if there is a new update with checkForUpdateAsync
  2. If it is available I check it’s release channel and show different modals depend on if it’s a new release channel or not

Here is the code, it’s pretty simple:

const update = await Updates.checkForUpdateAsync();
if (!update.isAvailable) return

const { isNew, manifest } = (await Updates.fetchUpdateAsync()) as {
    isNew: boolean;
    manifest: Updates.Manifest;
  };
  if (!isNew) return;
  if (isCurrentReleaseChannel(manifest.releaseChannel)) {
    showUpdateTheAppAlert();
  } else {
    showMandatoryAppUpdateAlert();
  }

This works really well for updates in the same release channel, but doesn’t work with new release channels. Please help me to figure out what I am doing wrong

What do you mean it ‘doesn’t work’? Is that binary built on the new release channel? Each build can only be associated with one release channel (for now)

1 Like

Hey Charlie! Thank you for your reply.

Yes we release a new binary build for every new release channel. When not only JS changes were added, but some native code.

What I expect is that users from previous builds receive information about this new build (in the code above I want to show them popup with recommendation of update). This doesn’t work, I am not sure where exactly, though. Either checkForUpdateAsync doesn’t return isAvailable flag or fetchUpdateAsync doesn’t return isNew flag. Also I have a lot of Sentry errors like “Failed to download manifest from URL: https://exp.host/@companyName/projectName*” - maybe the problem is here?

With simple JS updates within the same release channel I have no problems, everything works

Really appreciate any help

What I expect is that users from previous builds receive information about this new build

I don’t think that the best way to do this is by checking other release channels…instead I would hit a server from the app and compare the client’s version to the most recent version you’ve released - see a discussion here on why (the How in this discussion is outdated though, just FYI): How to check if new version of app is available. · Issue #251 · expo/expo · GitHub

You would get the Failed to download manifest from URL error if you’re trying to fetch an update from an unpublished channel

1 Like

checkForUpdateAsync will return isAvailable: false, because it only checks for updates that have the same release channel as the app. There’s no way built into expo-updates to check for builds in other channels.

The isNew flag is for if there are later builds in the app’s release channel.

1 Like

That’s pretty old. I believe the headers you should use have changed, right?

I think something like the following will let you check if there’s a build available for a given release channel, but off hand I’m not sure how to tell if it’s later than the one the app is currently using. It seems like keeping track of the builds for the different release channels on a separate web server that the app can poll might be easier?

http -j GET https://exp.host/@community/native-component-list \
    'Accept: application/expo+json,application/json' \
    'Expo-Api-Version: 1' \
    'Expo-Platform: android' \
    'Expo-Release-Channel: default' \
    'Expo-SDK-Version: 42.0.0' \
    'Expo-Updates-Environment: EXPO_DEVICE' \
    'Expo-JSON-Error: true' \
    'Expo-Accept-Signature: true'

Oh, I got it guys, expo-updates is built for updates within same release-channel. I think It will be cool if it would be documented clearly in docs. I hadn’t understood it, but I’ve read docs many times :slight_smile:

That will be really cool if Expo provides some way of getting information about new release-channel. Seems like our use case is pretty common. Otherwise we will setup our own endpoint for that.

Does this explain things a bit better?

Maybe some mention should also be made in the expo-updates docs.

1 Like

Yeah Carlie, I saw the issue about that, but it doesn’t look like our case. Because we have a step in our CI/CD which publishes new release channels. Even if sometimes we have a little delay, because binary build is published to stores earlier then we publish new release channel, these issues shouldn’t occur every day, especially when we don’t release anything. Are there any other ideas why it might be happening?

This is a very good page and it definitely explains a lot, but I’m not sure It makes clear that we can use methods from expo-updates only within same release-channel.

Well, it says “Your users will get the most recent compatible release”, and it says that releaseChannel is one of the things that affect compatibility.

So basically if the app was built with release channel X, and you publish to release channel Y, then the newly published build is “not compatible” because the release channels don’t match, so the app will not see it.

Also in the flowchart, the top yellow diamond shape says “Have we looked at all releases in the channel”. While this is not explicit, it means “the app’s channel”.

1 Like

@charliecruzan any thoughts on that, please?

If you’re certain that the URL it’s requesting is a valid Update url, then this could just be network issues. How often do you get this error?

I get the error many times a day from different android users, so it doesn’t look like network. Yes, the update url is valid, it’s https://exp.host/@company/app

That’s the entire URL? no release channel or sdk version?

No, are they must be there? In

<meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://exp.host/@company/app"/>

and

<key>EXUpdatesURL</key>
<string>https://exp.host/@company/app</string>

?

No sorry, that URL (without release channel) is expected, I just took a look at the error that’s being thrown

Instead of checking if https://exp.host/@company/app is a valid url, you should be checking if https://exp.host/@company/app?release-channel=yourreleasechannelhere is valid, or specifically https://exp.host/@company/app/index.exp?release-channel=yourreleasechannelhere&sdkVersion=<your-sdk-version>

The thing is I am not calling that URL purposely anywhere and getting the error, it is just happening. Maybe somewhere inside expo-updates or other expo package

Yep, the expo-updates package is requesting that URL itself when you run checkForUpdate or fetchUpdate

So, how can I make it requests a correct URL? With proper query params? Looks like it requests URL without them and gets the error