Skip to content

fix: auto-manage metro companion for remote runs#370

Merged
thymikee merged 7 commits intomainfrom
codex/metro-companion-auto-manage
Apr 10, 2026
Merged

fix: auto-manage metro companion for remote runs#370
thymikee merged 7 commits intomainfrom
codex/metro-companion-auto-manage

Conversation

@thymikee
Copy link
Copy Markdown
Contributor

@thymikee thymikee commented Apr 9, 2026

Summary

Auto-manage the local Metro companion for remote React Native runs so metro prepare / open --remote-config can 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 format
  • pnpm typecheck
  • pnpm check:unit

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://callstackincubator.github.io/agent-device/pr-preview/pr-370/

Built to branch gh-pages at 2026-04-10 07:41 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +511 to +513
} catch (error) {
lastBridgeError = error instanceof Error ? error.message : String(error);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +108 to +110
async function waitForSocketShutdown(socket: WebSocket): Promise<void> {
await new Promise<void>((resolve) => {
const finish = () => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@thymikee thymikee merged commit f3181a5 into main Apr 10, 2026
16 checks passed
@thymikee thymikee deleted the codex/metro-companion-auto-manage branch April 10, 2026 07:42
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