Skip to content

Commit 2361e61

Browse files
fix: propagate resolved port to build when default port is unavailable
When the default port (8081) is busy and the user accepts an alternative port, the resolved port was only used to start Metro but not propagated to args.port. This caused the iOS build (via RCT_METRO_PORT env var) and Android build (via -PreactNativeDevServerPort and adb reverse) to still use the original port, so the app would fail to connect to Metro.
1 parent b762402 commit 2361e61

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

  • packages
    • cli-platform-android/src/commands/runAndroid
    • cli-platform-apple/src/commands/runCommand

packages/cli-platform-android/src/commands/runAndroid/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ async function runAndroid(_argv: Array<string>, config: Config, args: Flags) {
7070
args.terminal,
7171
);
7272
}
73+
74+
if (newPort !== port) {
75+
args.port = newPort;
76+
}
7377
}
7478

7579
if (config.reactNativeVersion !== 'unknown') {

packages/cli-platform-apple/src/commands/runCommand/createRun.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ const createRun =
124124
args.terminal,
125125
);
126126
}
127+
128+
if (newPort !== port) {
129+
args.port = newPort;
130+
}
127131
}
128132

129133
if (ctx.reactNativeVersion !== 'unknown') {

0 commit comments

Comments
 (0)