You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: load Android e2e bundle via adb reverse instead of 10.0.2.2 - #1524
The Android e2e lane fails at random with "Unable to load script" on the first test (example run). A rerun passes.
Root cause: on a stock emulator, React Native connects to the dev server at 10.0.2.2:8081, which needs the emulator network. Right after boot, that network can be down for a short time. In the failed run, Wi-Fi came up, failed its check, and was turned off. Cellular came up about 30 s later. The app started inside that gap, could not reach the dev server, and fell back to an embedded bundle, which this app does not have. React Native checks for the dev server only once per start, so a longer test timeout does not help.
Fix: set the metro.host system property to localhost before the tests run. React Native reads it before falling back to 10.0.2.2 (AndroidInfoHelpers.kt). The app then reaches 8081 through the adb reverse tunnel the lane already sets up, and that tunnel does not use the emulator network. Port 8082 (the MF remote) already works this way.
adb root runs first, because setting the property may need root. It runs before the adb reverse lines, because restarting adbd can remove reverse rules.
The property is read back, and the job stops with a clear error if it was not set.
The other option was a wait loop that probes 10.0.2.2:8081 from inside the emulator before the tests. A wait loop only makes the race less likely, while metro.host removes it.
Test plan
CI: the Android e2e job passes the metro.host not set check.
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Android e2e lane fails at random with "Unable to load script" on the first test (example run). A rerun passes.
Root cause: on a stock emulator, React Native connects to the dev server at
10.0.2.2:8081, which needs the emulator network. Right after boot, that network can be down for a short time. In the failed run, Wi-Fi came up, failed its check, and was turned off. Cellular came up about 30 s later. The app started inside that gap, could not reach the dev server, and fell back to an embedded bundle, which this app does not have. React Native checks for the dev server only once per start, so a longer test timeout does not help.Fix: set the
metro.hostsystem property tolocalhostbefore the tests run. React Native reads it before falling back to10.0.2.2(AndroidInfoHelpers.kt). The app then reaches 8081 through theadb reversetunnel the lane already sets up, and that tunnel does not use the emulator network. Port 8082 (the MF remote) already works this way.adb rootruns first, because setting the property may need root. It runs before theadb reverselines, because restarting adbd can remove reverse rules.The other option was a wait loop that probes
10.0.2.2:8081from inside the emulator before the tests. A wait loop only makes the race less likely, whilemetro.hostremoves it.Test plan
CI: the Android e2e job passes the
metro.host not setcheck.