fix: auto-manage metro companion for remote runs#370
Conversation
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 606068c127
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } catch (error) { | ||
| lastBridgeError = error instanceof Error ? error.message : String(error); | ||
| } |
There was a problem hiding this comment.
Fail fast on non-recoverable bridge errors
The retry loop catches all configureMetroBridge errors and keeps retrying until startupTimeoutMs, which means permanent client-side failures (for example a 401 from an invalid bearer token or a bad proxy endpoint) now stall metro prepare/open --remote-config for up to the full timeout (default 180s) before returning an error. This regresses fast feedback and can make remote runs look hung; non-transient bridge failures should be surfaced immediately instead of being retried for the full window.
Useful? React with 👍 / 👎.
| async function waitForSocketShutdown(socket: WebSocket): Promise<void> { | ||
| await new Promise<void>((resolve) => { | ||
| const finish = () => { |
There was a problem hiding this comment.
Guard shutdown wait against already-closed sockets
waitForSocketShutdown waits only on future close/error events and does not short-circuit when the socket is already CLOSING/CLOSED. If the bridge disconnects immediately after opening (before these listeners are attached), this promise can wait forever, which prevents the companion loop from reconnecting and leaves proxying stuck until the process is restarted.
Useful? React with 👍 / 👎.
Summary
Auto-manage the local Metro companion for remote React Native runs so
metro prepare/open --remote-configcan recover when the bridge is missing a local tunnel.Add companion lifecycle management, worker-level websocket coverage, close-path cleanup, and docs/skill updates.
Touched files: 14. Scope stayed within the remote Metro/open flow, companion worker, targeted tests, and related docs/skills.
Validation
pnpm formatpnpm typecheckpnpm check:unit