expo: [expo-updates][iOS] Initial call to fetchUpdateAsync() fails, succeeds on subsequent calls
Summary
We’re developing a ReactNative app using the Expo bare workflow and ReactNativeNavigation for our navigation library. Recently, we updated from Expo 39 to Expo 42. Before doing so, we never had a problem with OTA publishing with our existing code. After the update, however, we are finding that fetchUpdateAsync() fails perhaps 75% of the time or so after we have published an OTA update and restarted our app. Examining the captured error does not provide much information, but it seems the error.code is ERR_UPDATES_FETCH, the error.message is Failed to download new update, and the error.domain is EXUpdatesDatabase.
When an error occurs, we present the user with an alert box with the option to retry (see code below). Upon retrying, fetchUpdateAsync() succeeds.
Since this error does not occur on every update and since it’s possible to just re-run fetchUpdateAsync() and the fetch will succeed on the second call, it seems likely that we’re facing some sort of timeout (or region-related? Our team is based in Japan) issue. Is there an obvious fix for this that I’m missing besides checking for the returned error code and re-running fetchUpdateAsync()? Thank you.
Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!
bare
What platform(s) does this occur on?
iOS
SDK Version (managed workflow only)
No response
Environment
Expo CLI 4.11.0 environment info:
System:
OS: macOS 11.5.1
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.1.0 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 7.21.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
Android SDK:
API Levels: 29, 31
Build Tools: 29.0.2, 31.0.0
System Images: android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7621141
Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
npmPackages:
@expo/webpack-config: ~0.14.0 => 0.14.0
expo: ^42.0.0 => 42.0.3
react: 17.0.1 => 17.0.1
react-dom: 17.0.1 => 17.0.1
react-native: 0.64.1 => 0.64.1
react-native-web: ~0.17.1 => 0.17.1
npmGlobalPackages:
expo-cli: 4.11.0
Expo Workflow: bare
Reproducible demo or steps to reproduce from a blank project
Obviously, a release build is required in order to test this (as expo-updating only works for release builds) so it isn’t possible to provide a snack that reproduces the issue we’re seeing, but this is the relevant code:
const checkForUpdatesAndRenderNavigation = async () => {
try {
const otaUpdate = await Updates.checkForUpdateAsync();
if (otaUpdate.isAvailable) {
await Updates.fetchUpdateAsync();
await Updates.reloadAsync();
return;
}
renderNavigationRoot();
} catch (error) {
showRetryAlert(error, checkForUpdatesAndRenderNavigation);
}
};
const showRetryAlert = (error, onRetryPress) => {
Alert.alert(
'Something went wrong',
`error: ${error}`,
[
{
text: showRetryAlertRetryButton(),
onPress: () => onRetryPress(),
},
],
);
};
// app.json
{
"expo": {
...
"updates": {
"fallbackToCacheTimeout": 0,
"checkAutomatically": "ON_ERROR_RECOVERY"
},
...
}
}
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 14
- Comments: 23 (7 by maintainers)
Bump
Same issue here on bare workflow. Expo v43
fetchUpdateAsyncthrows an error, and but it looks as though the update has been downloaded. You canreloadAsyncincatchand the update will be applied. Weird.I get the following error message:
I’m seeing this error when using EAS build on development clients…
In case it is a region issue I’ll add that we experience this in Australia. We do the same thing now with a retry button.
Hi, I had the same issue and it drove me crazy and had a hard time finally landing on that issue ! I happened to actually have some calls to Constants.manifest, though they were safe calls : e.g
Constants.manifest?.expoVersion, but removing them finally did the trick@esamelson not a reproducable repo, but here is the output of
nativeStackIOSfor us. Hopefully this helps.Similar to @Maker-Mark, this is on an EAS Production OTA update.
EDIT: This was magically fixed after removing all calls to
Constants.manifest. I’m not sure if this is related, but updates are working for now 🙌Hi everyone, I attempted to make a reproduction of this issue but was unable to. Here’s the repo: https://github.com/jonsamp/test-3-9-fetch-updates/tree/main
Inside the README.md are the steps I took and a video example of loading an update on app refocus. If anyone can modify this repo in a way to reproduce the bug, then we can get to the bottom of this issue.
Seeing this randomly as well, located in the USA. We’re fetching the updates before presenting an option to apply them, but seeing the failures logged to Sentry.