eas-cli: eas update missing --clear-cache option

Build/Submit details page URL

https://expo.dev/accounts/kavyar-org/projects/kavyar-app/updates/d58a32ad-7c5a-4122-8def-29c85401bb7d

Summary

eas update seems to be missing a --clear-cache option. expo publish had this option and eas build has it. Not having it is causing problems with our app updates.

We are using a STAGE environment variable to auto-configure our app for the appropriate release environment (dev, staging, production). We inject it into the app using eas.json, app.config.js, and the Constants.manifest2?.extra?.expoClient?.extra?.eas?.STAGE technique recommended in the docs.

This works fine for the initial EAS build. However, when we do eas update, the generated bundle will often have a stale value (from a prior build) for the STAGE var that gets injected via Constants.

We used to use the --clear option with expo publish to work around this, but that option is not available for eas update.

This recently caused a staging config to be released into our production app, which created quite a mess.

Managed or bare?

Managed

Environment

  expo-env-info 1.0.3 environment info:
    System:
      OS: macOS 12.2.1
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
      Yarn: 1.22.18 - /opt/homebrew/bin/yarn
      npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm
    SDKs:
      iOS SDK:
        Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
      Android SDK:
        API Levels: 31
        Build Tools: 31.0.0, 32.0.0
        System Images: android-31 | Google APIs ARM 64 v8a
    IDEs:
      Android Studio: 2020.3 AI-203.7717.56.2031.7784292
      Xcode: 13.4/13F17a - /usr/bin/xcodebuild
    npmPackages:
      babel-preset-expo: ~9.1.0 => 9.1.0 
      expo: ^45.0.0 => 45.0.4 
      react: 17.0.2 => 17.0.2 
      react-dom: 17.0.2 => 17.0.2 
      react-native: 0.68.2 => 0.68.2 
      react-native-web: 0.17.7 => 0.17.7 
    npmGlobalPackages:
      eas-cli: 0.52.0
      expo-cli: 5.4.7
    Expo Workflow: managed

Error output

No response

Reproducible demo or steps to reproduce from a blank project

Hopefully the issue is clear enough not to need an isolated reproduction. If a reproduction is required, let me know and I will see if our team has time to create one.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (3 by maintainers)

Most upvoted comments

I’ve landed a PR that will add the a --clear-cache flag to eas update to clear the metro bundler cache. It will be available in the next patch release of eas-cli.

For me the problem is with my environment variables. When I’m running my project locally using local servers and I use eas update, the production app starts trying to make requests on localhost… What a mess.

I also ran into this (this is still tagged as need review) and it has actually broken our production envs a few times as well as leaking development and test values into production apps.

Even if you log in app.config.ts env-provided values, the dist folder will have still the old data. Even purging the dist folder before building still generated the old data, meaning that (likely) the bundler holds some transform cache somewhere, probably relating to babel.

expo export --experimental-bundle --clear

whilst this seems to maybe work consistently, doesn’t this force an extra build? Or will the eas update afterwards just pick up that build instead?

@kbrandwijk It seems like the command option is actually --clear and not --clear-cache.

You are right that such an option doesn’t exist yet, and that this will cause issues when only environment variables are updated, making the bundler think nothing has changed. We are looking into the best solution for this internally, but in the meantime, there is a workaround.

You can run expo export --experimental-bundle --clear-cache, which will force the dist folder to be updated. After that, running eas update as normal will use the updated bundle for the update.

Update: as pointed out below, it’s expo export --experimental-bundle --clear