Skip to content

fix: clean up metro companion workers#376

Merged
thymikee merged 3 commits into
mainfrom
codex/fix-metro-companion-cleanup
Apr 11, 2026
Merged

fix: clean up metro companion workers#376
thymikee merged 3 commits into
mainfrom
codex/fix-metro-companion-cleanup

Conversation

@thymikee

Copy link
Copy Markdown
Member

Summary

Tighten metro companion cleanup so detached workers do not survive test or runtime teardown.
The companion now treats its state file as a lease, removes log and state artifacts when fully stopped, and the installed-package integration test always stops the tunnel and removes temp state in finally.

Validation

  • pnpm format
  • pnpm vitest run src/__tests__/client-metro-companion.test.ts src/__tests__/client-metro-companion-worker.test.ts
  • pnpm check:unit
  • node --test test/integration/installed-package-metro.test.ts

@github-actions

github-actions Bot commented Apr 10, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

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

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

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

Copy link
Copy Markdown

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: 4533726b9c

ℹ️ 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".

}
}, METRO_COMPANION_RECONNECT_DELAY_MS);
lifetimeHandle.unref();
while (shouldKeepWorkerRunning(options)) {

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 Avoid lease check before first worker iteration

The new while (shouldKeepWorkerRunning(options)) gate can make a freshly spawned companion exit immediately on cold start, because ensureMetroCompanion still writes the lease/state file only after spawning the process (src/client-metro-companion.ts), so if the child reaches this condition first it sees no file and returns without ever registering. This introduces a startup race that can leave a dead PID in state and cause metro tunnel setup to fail intermittently until retried.

Useful? React with 👍 / 👎.

@thymikee thymikee force-pushed the codex/fix-metro-companion-cleanup branch from 4533726 to 95b7273 Compare April 10, 2026 18:58
@thymikee thymikee merged commit 897c25d into main Apr 11, 2026
16 checks passed
@thymikee thymikee deleted the codex/fix-metro-companion-cleanup branch April 11, 2026 07:38
thymikee added a commit that referenced this pull request Apr 11, 2026
…cation-simplify

* origin/main:
  test: stabilize android emulator boot tests (#377)
  fix: clean up metro companion workers (#376)
  fix: carry remote-config run id for install-from-source (#375)
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