Skip to content

feat: configurable Metro port#79

Open
mfazekas wants to merge 1 commit intocallstackincubator:mainfrom
mfazekas:feat/configurable-metro-port
Open

feat: configurable Metro port#79
mfazekas wants to merge 1 commit intocallstackincubator:mainfrom
mfazekas:feat/configurable-metro-port

Conversation

@mfazekas
Copy link
Contributor

@mfazekas mfazekas commented Mar 20, 2026

Summary

Adds a metroPort config option (defaults to 8081) so harness tests can run on a non-default Metro port. This enables running independent harness sessions across git worktrees and avoids conflicts when port 8081 is already in use.

  • iOS simulator: sets RCT_jsLocation via xcrun simctl spawn ... defaults write
  • Android: writes debug_http_host SharedPreferences via adb shell run-as + sets up adb reverse for the configured port
  • iOS physical devices: throws if non-default port is configured (no remote NSUserDefaults access)
  • Always writes the port preference on startup (even for default 8081) to recover from stale state after crashes

Usage

// rn-harness.config.mjs
export default {
  metroPort: 8082,
  // ...
};

Or via CLI:

npx jest --config jest.harness.config.mjs --metroPort 8082

Limitations

  • Parallel worktrees must use different simulators/emulators — the port preference is per-bundle-ID per-device, so two sessions targeting the same device would race.
  • iOS physical devices don't support custom Metro ports (no way to set RCT_jsLocation remotely).

Test plan

  • Typecheck passes across all 20 packages
  • All unit tests pass (48 tests)
  • iOS simulator: smoke test passes with metroPort: 8082 while 8081 is occupied
  • Android emulator: smoke test passes with metroPort: 8082 while 8081 is occupied
  • Default port (8081) correctly fails with Metro port 8081 is not available when occupied

@vercel
Copy link

vercel bot commented Mar 20, 2026

@mfazekas is attempting to deploy a commit to the Callstack Team on Vercel.

A member of the Team first needs to authorize it.

@mfazekas mfazekas force-pushed the feat/configurable-metro-port branch from 35d6904 to 6b5d353 Compare March 20, 2026 06:47
@mfazekas mfazekas force-pushed the feat/configurable-metro-port branch from 6b5d353 to 841c099 Compare March 20, 2026 06:53
@mfazekas mfazekas marked this pull request as ready for review March 20, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant