question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`Update.reloadAsync` does not update the local bundle

See original GitHub issue

Summary

I am building an app and am using expo-updates. I am able to create updates, and the app is able to fetch them via Updates.checkForUpdateAsync() and Updates.fetchUpdateAsync(). However, after those two method calls, invoking Updates.reloadAsync() restarts the app, but does not update the JS bundle.

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

managed

What platform(s) does this occur on?

iOS

SDK Version (managed workflow only)

44.0.6

Environment

expo-env-info 1.0.3 environment info: System: OS: macOS 12.0.1 Shell: 5.8 - /bin/zsh Binaries: Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node Yarn: 1.22.17 - ~/.nvm/versions/node/v14.18.1/bin/yarn npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm Watchman: 2022.02.14.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /Users/nate/.gem/ruby/2.7.2/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5 IDEs: Xcode: 13.3.1/13E500a - /usr/bin/xcodebuild npmPackages: expo: 44.0.1 => 44.0.1 react: 17.0.1 => 17.0.1 react-dom: 17.0.1 => 17.0.1 react-native: 0.64.3 => 0.64.3 react-native-web: 0.17.1 => 0.17.1 npmGlobalPackages: eas-cli: 0.47.0 Expo Workflow: managed

Reproducible demo

Here is my simple component that illustrates the problem:

// Vendor
import { useEffect, useState } from 'react';
import { View, Text } from 'react-native';
import * as Updates from 'expo-updates';
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
// Components
import BaseLayout from '~/components/layouts/base_layout';
import Button from '~/components/shared/button';
// Misc
import { tailwind } from '~/utils/tailwind';

const ListingSearchScreen = () => {
  const [update, setUpdate] = useState(undefined);

  const checkForUpdate = async () => {
    try {
      const update = await Updates.checkForUpdateAsync();
      setUpdate(update);
    } catch (error) {
      alert(`Error fetching latest Expo update: ${error}`);
    }
  }

  const fetchUpdate = async () => {
    try {
      const res = await Updates.fetchUpdateAsync();
      setUpdate(res);
      alert('Updated successfully fetched!')
    } catch (error) {
      alert(`Error fetching latest Expo update: ${error}`);
    }
  };

  const reload = async () => {
    try {
      await Updates.reloadAsync();
      alert('Reloaded!')
    } catch (error) {
      alert(`Error reloading: ${error}`);
    }
  };

  useEffect(async () => {
    checkForUpdate();
  }, []);

  return (
    <View style={tailwind('h-full bg-grayMutedBg')}>

      <BaseLayout.NoPadding hasNoHeader style={tailwind('flex-1')}>
        <KeyboardAwareScrollView>
        {
          update && (
            <View>
              <Button type="primary" onPress={fetchUpdate}>
                Fetch Update
              </Button>
              <Button type="primary" onPress={reload}>
                Reload
              </Button>
              <Text>{JSON.stringify(update, null, 2)}</Text>
            </View>
          )
        }
        {!update && <View><Text>No Update Yet</Text></View>}
        </KeyboardAwareScrollView>
      </BaseLayout.NoPadding>
    </View>
  );
};

export default ListingSearchScreen;

Code Walkthrough

On App Load

  • Updates.checkForUpdateAsync is called on mount.
  • You can see that the update is fetched, stored in the local state, and then shown in the UI. Note: isAvailable is set to true
  • Notice the updateGroup: 5b9d8e29-1a79-49ba-971a-3d49a5734b54 Slice 1

On click Fetch Update button

  • This invokes Updates.fetchUpdateAsync()
  • We store this response in the state and show it in the UI. **Note: ** the UI now shows isNew is set to true, as opposed to isAvailable Slice 2

On click Reload button

  • At this point, if we reload the app, it should update the local JS code with the new bundle that was fetched in the previous state.
  • We would expect the app to reload, mount, check for any new updates (there shouldn’t be any), and then show that there is no update available in the UI. However, it shows the same update from last time.
  • Notice that the updateGroup has not changed Slice 1

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
rosexicommented, Apr 29, 2022

I’m experiencing this same issue after upgrading from expo 42 to 44. After reloadAsync, the previous update shows instead of the newly downloaded one.

3reactions
rosexicommented, Jun 27, 2022

I encountered the same issue on expo 45. I tried building with jsc instead of hermes, and now updates are working. Additionally, updates are working with Android when I build with jsc as well.

Seems it doesn’t work with hermes? I’m using jsc for now as a workaround.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Updates - Expo Documentation
Updates.reloadAsync() ... Instructs the app to reload using the most recently downloaded version. This is useful for triggering a newly downloaded update to ......
Read more >
expo-updates - npm
Expo can automatically bundle your most recent update into your iOS and Android binaries, so that users can launch your app immediately for ......
Read more >
Newest 'expo-updates' Questions - Stack Overflow
Expo update: reloadAsync crashes app in release build. I want to restart my react native app when I ... Eas Update does not...
Read more >
How to implement over the air updates with expo ... - Red Shift
In order to swap out this bundle, the app needs to know that there's an update available, download it from some online source,...
Read more >
Expo SDK 37 is now available - DEV Community ‍ ‍
If you want to re-run expo build, then you'll need to upgrade from SDK 33, preferably to SDK 37 so you won't need...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found