Skip to content

feat: configurable Metro port#79

Merged
V3RON merged 6 commits intocallstackincubator:mainfrom
mfazekas:feat/configurable-metro-port
Mar 23, 2026
Merged

feat: configurable Metro port#79
V3RON merged 6 commits intocallstackincubator:mainfrom
mfazekas:feat/configurable-metro-port

Conversation

@mfazekas
Copy link
Copy Markdown
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
Copy Markdown

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
@V3RON
Copy link
Copy Markdown
Contributor

V3RON commented Mar 23, 2026

Hey @mfazekas 👋
I went ahead and pushed a few changes so --metroPort now ends up in HarnessConfig, and the changes to shared prefs and iOS defaults are reverted after the run. Let me know what you think.

@mfazekas
Copy link
Copy Markdown
Contributor Author

@V3RON thanks much! Yes both changes make sense to me 👍

@V3RON V3RON merged commit 6b2de9e into callstackincubator:main Mar 23, 2026
1 of 2 checks passed
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.

2 participants