1--- 2title: Advanced EAS Update Debugging 3sidebar_title: Advanced 4description: Learn advanced strategies on how to debug EAS Update. 5--- 6 7import ImageSpotlight from '~/components/plugins/ImageSpotlight'; 8import { Terminal } from '~/ui/components/Snippet'; 9 10After verifying our EAS Update configuration in our [basic guide](/eas-update/debug), we can move on to more advanced debugging strategies. The following sections describe common classes of problems and strategies on how to tackle them. 11 12## General strategies 13 14Try these strategies before using the more specific ones mentioned in this guide. 15 16### Use `expo-dev-client` 17 18Create a [development version of our build](/eas-update/expo-dev-client). It will help us preview published updates inside a problematic build. 19 20### In-app debugging 21 22The `expo-updates` library exports a variety of functions to interact with updates once the app is already running. In certain cases, making a call to fetch an update and seeing an error message can help us narrow down the root cause. We can make a simulator build of the project and manually check to see if updates are available or if there are errors when fetching updates. 23 24- Print the [Update.Constants](/versions/latest/sdk/updates/#constants) to verify our configuration. 25- [Examine log entries](/versions/latest/sdk/updates/#updatesreadlogentriesasyncmaxage) surfaced from the native layer. 26- Fetch and [load updates manually](/versions/latest/sdk/updates/#check-for-updates-manually). 27 28## Configuration issues 29 30Our app is still not receiving the expected update despite following the [basic guide](/eas-update/debug). 31 32### `expo-updates` configuration 33 34The `expo-updates` library runs inside an end-user's app and makes requests to an update server to get the latest update. 35 36#### Verifying app configuration 37 38When we set up EAS Update, we likely ran `eas update:configure` to configure expo-updates to work with EAS Update. This command makes changes to our app config (**app.json**/**app.config.js**). Here are the fields we'd expect to see: 39 40- `runtimeVersion` should be set. By default, it is `{ "policy": "sdkVersion" }`. If our project has **android** and **ios** directories, we'll have to set the `runtimeVersion` manually. 41- `updates.url` should be a value like `https://u.expo.dev/your-project-id`, where `your-project-id` matches the ID of our project. We can see this ID on [our website](https://expo.dev/accounts/[account]/projects/[project]). 42- `updates.enabled` should not be `false`. It's `true` by default if it is not specified. 43 44Finally, make sure that `expo-updates` is included in **package.json**. If it's not, run: 45 46<Terminal cmd={['$ npx expo install expo-updates']} /> 47 48#### Inspecting expo-updates configuration after prebuild 49 50Whenever we run `eas build`, the `npx expo prebuild` command is run on our project on EAS' servers to unpack the **android** and **ios** directories that contain native files. This makes it so EAS Build can build any project, whether it includes the native files or not. 51 52If our project does not have **android** or **ios** directories, we can make commit any existing changes, then run `npx expo prebuild` to inspect the project state that EAS Build will act on. After running this, look for the following files: **android/app/src/main/AndroidManifest.xml** and **ios/your-project-name/Supporting/Expo.plist**. 53 54In each, we expect to see configuration for the EAS Update URL and the runtime version. Here are the properties we'd expect to see in each file: 55 56**AndroidManifest.xml** 57 58```xml 59... 60<meta-data android:name="expo.modules.updates.EXPO_RUNTIME_VERSION" android:value="your-runtime-version-here"/> 61<meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://u.expo.dev/your-project-id-here"/> 62... 63``` 64 65**Expo.plist** 66 67```xml 68... 69<key>EXUpdatesRuntimeVersion</key> 70<string>your-runtime-version-here</string> 71<key>EXUpdatesURL</key> 72<string>https://u.expo.dev/your-project-id-here</string> 73... 74``` 75 76### Configuration without EAS Build 77 78If we aren't using EAS Build, this section will walk through debugging the state of EAS Update in our project. We'll need to look at multiple spots in the system. Below is a diagram of how EAS Update works and the spots that are useful to inspect when finding the root cause of an issue. In the sections following, we'll inspect and verify these spots and more. 79 80<ImageSpotlight alt="Map of debugging spots" src="/static/images/eas-update/debug-map.png" /> 81 82#### Verify build configuration 83 84Follow the [Building Locally guide](/eas-update/build-locally) to configure our app's channel and runtime version. We'll also need to make sure our [general configuration](/eas-update/debug-advanced/#expo-updates-configuration) is correct. 85 86#### Verify the channel 87 88Builds have a property named `channel`, which EAS Update uses to link to a branch. A channel is often given to multiple platform-specific builds. For instance, we might have an Android build and an iOS build, both with a channel named `"production"`. 89 90Once a build has a channel name, we can make sure that EAS' servers know about it by checking the [Channels page](https://expo.dev/accounts/[account]/projects/[project]/channels). 91 92We'd expect the page to display the same channel name that our build has. If it's not there, we can create the channel on EAS' servers with: 93 94<Terminal 95 cmd={[ 96 '# eas channel:create [channel-name]', 97 '', 98 '', 99 '# Example', 100 'eas channel:create production', 101 ]} 102/> 103 104#### Verify the channel/branch mapping 105 106There is a link that is defined by the developer between a channel and a branch. When a channel and branch are linked, an app with a channel will get the most recent compatible update on the linked branch. 107 108The [Channels page](https://expo.dev/accounts/[account]/projects/[project]/channels) will display the channel to branch mapping if it exists. 109 110<ImageSpotlight 111 alt="Linked branches on the Channels page" 112 src="/static/images/eas-update/channels-linked-branches.png" 113 style={{ maxWidth: 400 }} 114/> 115 116If the channel is not linked to the branch we expect, we can change the link with: 117 118<Terminal 119 cmd={[ 120 '# eas channel:edit [channel-name] --branch [branch-name]', 121 '', 122 '', 123 '# Example', 124 'eas channel:edit production --branch release-1.0', 125 ]} 126/> 127 128#### Verify the update 129 130Every branch contains a list of updates. When a build makes a call for an update, we find the channel of the build, then the branch linked to that channel. Once the branch is found, EAS will return the most recent compatible update on that branch. A build and an update are compatible when they share the same runtime version and platform. 131 132To inspect which updates are on a branch, we can go to the [Branches page](https://expo.dev/accounts/[account]/projects/[project]/branches) and choose our branch of interest. 133 134The Branch Detail page will show us a list of updates and their runtime versions and platforms. From this list, we should be able to figure out which update should apply to a given build, by matching the build's runtime version and platform to update's runtime version and platform. The most recent update that is compatible will be available for a build to download and execute. 135 136<ImageSpotlight 137 alt="List of updates on the Branch Detail page" 138 src="/static/images/eas-update/branch-update-list.png" 139 style={{ maxWidth: 800 }} 140/> 141 142## Debugging EAS Update 143 144After verifying `expo-updates` and EAS Update configurations, we can move on to debugging how our project is interacting with updates. 145 146### In-app debugging 147 148The `expo-updates` library exports a variety of functions to interact with updates once the app is already running. In certain cases, making a call to fetch an update and seeing an error message can help us narrow down the root cause. We can make a simulator build of the project and manually check to see if updates are available or if there are errors when fetching updates. See the code example to [check for updates manually](/versions/latest/sdk/updates/#use-expo-updates-with-a-custom-server). 149 150### Viewing network requests 151 152Another way to identify the root cause of an issue is to look at the network requests that the app is making to EAS servers, then viewing the responses. We recommend using a program like [Proxyman](https://proxyman.io/) or [Charles Proxy](https://www.charlesproxy.com/) to watch network requests from our app. 153 154With either program, we'll need to follow their instructions for installing an SSL certificate, so that the program can decode HTTPS requests. Once that's set up in a simulator or on an actual device, we can open our app and watch requests. 155 156The requests we're interested in are from https://u.expo.dev and https://assets.eascdn.net. Responses from https://u.expo.dev will contain an update manifest, which specifies which assets the app will need to fetch to run the update. Responses from https://assets.eascdn.net will contain assets, like images, font files, and so on, that are required for the update to run. 157 158When inspecting the request to https://u.expo.dev, we can look for the following request headers: 159 160- `Expo-Runtime-Version`: this should make the runtime version we made our build and update with. 161- `expo-channel-name`: this should be the channel name specified in the **eas.json** build profile. 162- `Expo-Platform`: this should be either "android" or "ios". 163 164As for all requests, we expect to see either `200` response codes, or `304` if nothing has changed. 165 166Below is a screenshot showing the request of a successful update manifest request: 167 168<ImageSpotlight 169 alt="Successful manifest request" 170 src="/static/images/eas-update/network-request.png" 171/> 172 173### Inspecting a build manually 174 175When building a project into an app, there can be multiple steps that alter the output of `npx expo prebuild`. After making a build, it is possible to open the build's contents and inspect native files to see its final configuration. 176 177Here are the steps for inspecting an iOS Simulator build on macOS: 178 1791. Create an iOS Simulator build of the app using EAS Build. This is done by adding `"ios": { "simulator": true }` to a build profile. 1802. Once the build is finished, download the result and unzip it. 1813. Then, right click on the app and select "Show Package Contents". 1824. From there, we can inspect the **Expo.plist** file. 183 184Inside the **Expo.plist** file, we expect to see the following configurations: 185 186```xml 187... 188<key>EXUpdatesRequestHeaders</key> 189<dict> 190 <key>expo-channel-name</key> 191 <string>your-channel-name</string> 192</dict> 193<key>EXUpdatesRuntimeVersion</key> 194<string>your-runtime-version</string> 195<key>EXUpdatesURL</key> 196<string>https://u.expo.dev/your-project-id</string> 197... 198``` 199 200### Inspecting manifests manually 201 202When an update is published with EAS Update, we create a manifest that end-user app's request. The manifest has information like which assets and versions are needed for an update to load. We can inspect the manifest by going to a specific URL in a browser or by using `curl`. 203 204Inside our project's app config (**app.json**/**app.config.json**), the URL we can GET is under `updates.url`. 205 206This `url` is EAS' "https://u.expo.dev" domain, followed by the project's ID on EAS' servers. If we go to the URL directly, we'll see an error about missing a header. We can view a manifest by adding three query parameters to the URL: `runtime-version`, `channel-name`, and `platform`. If we published an update with a runtime version of `1.0.0`, a channel of `production` and a platform of `android`, the full URL we could visit would be similar to this: 207 208``` 209https://u.expo.dev/your-project-id?runtime-version=1.0.0&channel-name=production&platform=android 210``` 211 212### Viewing network requests 213 214Another way to identify the root cause of an issue is to look at the network requests that the app is making to EAS servers, then viewing the responses. We recommend using a program like [Proxyman](https://proxyman.io/) or [Charles Proxy](https://www.charlesproxy.com/) to watch network requests from our app. 215 216With either program, we'll need to follow their instructions for installing an SSL certificate, so that the program can decode HTTPS requests. Once that's set up in a simulator or on an actual device, we can open our app and watch requests. 217 218The requests we're interested in are from https://u.expo.dev and https://assets.eascdn.net. Responses from https://u.expo.dev will contain an update manifest, which specifies which assets the app will need to fetch to run the update. Responses from https://assets.eascdn.net will contain assets, like images, font files, and so on, that are required for the update to run. 219 220When inspecting the request to https://u.expo.dev, we can look for the following request headers: 221 222- `Expo-Runtime-Version`: this should make the runtime version we made our build and update with. 223- `expo-channel-name`: this should be the channel name specified in the **eas.json** build profile. 224- `Expo-Platform`: this should be either "android" or "ios". 225 226As for all requests, we expect to see either `200` response codes, or `304` if nothing has changed. 227 228Below is a screenshot showing the request of a successful update manifest request: 229 230<ImageSpotlight 231 alt="Successful manifest request" 232 src="/static/images/eas-update/network-request.png" 233/> 234 235## Runtime issues 236 237We are able to load the expected update but our project is displaying unexpected behavior. 238 239### Debugging of native code while loading the app through expo-updates 240 241By default, we need to make a release build for `expo-updates` to be enabled and to load updates rather than reading from a development server. This is because debug builds behave like normal React Native project debug builds. 242 243To make it easier to test and debug native code in an environment that is closer to production, follow the steps below to create a debug build of the app with `expo-updates` enabled. 244 245We also provide a [step-by-step guide to try out EAS Update quickly](/eas-update/build-locally) in a local development environment using Android Studio or Xcode, with either release or debug builds of the app. 246 247#### iOS local builds 248 249- Set the debug environment variable: `export EX_UPDATES_NATIVE_DEBUG=1` 250- Reinstall pods with `npx pod-install`. The `expo-updates` podspec now detects this environment variable, and makes changes so that the debug code that would normally load from the Metro packager is bypassed, and the app is built with the EXUpdates bundle and other dependencies needed to load updates from EAS. 251- [Ensure the desired channel is set in our **Expo.plist**](/eas-update/updating-your-app/#configuring-the-channel-manually) 252- Modify the application Xcode project file to force bundling of the application JavaScript for both release and debug builds: 253 254``` 255sed -i '' 's/SKIP_BUNDLING/FORCE_BUNDLING/g;' ios/<project name>.xcodeproj/project.pbxproj 256``` 257 258- Execute a [debug build](/debugging/runtime-issues/#native-debugging) of the app with Xcode or from the command line. 259 260#### Android local builds 261 262- Set the debug environment variable: `export EX_UPDATES_NATIVE_DEBUG=1` 263- [Ensure the desired channel is set in your **AndroidManifest.xml**](/eas-update/updating-your-app/#configuring-the-channel-manually) 264- Execute a [debug build](/debugging/runtime-issues/#native-debugging) of the app with Android Studio or from the command line. 265 266#### EAS Build 267 268Alternatively, we can use EAS to create a debug build where `expo-updates` is enabled. The environment variable is set in **eas.json**, as shown in the example below: 269 270```json eas.json 271{ 272 "build": { 273 "preview_debug": { 274 "env": { 275 "EX_UPDATES_NATIVE_DEBUG": "1" 276 }, 277 "android": { 278 "distribution": "internal", 279 "withoutCredentials": true, 280 "gradleCommand": ":app:assembleDebug" 281 }, 282 "ios": { 283 "simulator": true, 284 "buildConfiguration": "Debug" 285 }, 286 "channel": "preview_debug" 287 } 288 } 289} 290``` 291 292## Publishing issues 293 294We are not able to publish an update, or parts of our update are not being published as expected. 295 296### Inspecting the latest update locally 297 298When we publish an update with EAS Update, it creates a **/dist** folder in the root of our project locally, which includes the assets that were uploaded as a part of the update. 299 300<ImageSpotlight alt="Dist directory" src="/static/images/eas-update/dist.png" /> 301 302### Viewing all assets included in an update 303 304It may be helpful to see which assets are included in our update bundle. We can see a list of named assets by running: 305 306<Terminal cmd={['$ npx expo export']} /> 307 308## Mitigation steps 309 310Once we've found the root cause of the issue, there are various mitigation steps we might want to take. One of the most common problems is pushing an update that has a bug inside it. When this happens, we can re-publish a previous update to resolve the issue. 311 312### Re-publishing a previous update 313 314The fastest way to "undo" a bad publish is to re-publish a known good update. Imagine we have a branch with two updates: 315 316```bash 317branch: "production" 318updates: [ 319 update 2 (id: xyz2) "fixes typo" // bad update 320 update 1 (id: abc1) "updates color" // good update 321] 322``` 323 324If "update 2" turned out to be a bad update, we can re-publish "update 1" with a command like this: 325 326<Terminal 327 cmd={[ 328 '# eas update:republish --group [update-group-id]', 329 '', 330 '# eas update:republish --branch [branch-name]', 331 '', 332 '', 333 '# Example', 334 '$ eas update:republish --group abc1', 335 '$ eas update:republish --branch production', 336 ]} 337/> 338 339The example command above would result in a branch that now appears like this: 340 341```bash 342branch: "production" 343updates: [ 344 update 3 (id: def3) "updates color" // re-publish of update 1 (id: abc1) 345 update 2 (id: xyz2) "fixes typo" // bad update 346 update 1 (id: abc1) "updates color" // good update 347] 348``` 349 350Since "update 3" is now the most recent update on the "production" branch, all users who query for an update in the future will receive "update 3" instead of the bad update, "update 2". 351 352While this will prevent all new users from seeing the bad update, users who've already received the bad update will run it until they can download the latest update. Since mobile networks are not always able to download the most recent update, sometimes users may run a bad update for a long time. When viewing error logs for our app, it's normal to see a lingering long tail of errors as our users' apps get the most recent update or build. We'll know we solved the bug when we see the error rate decline dramatically; however, it likely will not disappear completely if we have a diverse user base across many locations and mobile networks. 353