fix: clean up metro companion workers#376
Conversation
|
There was a problem hiding this comment.
💡 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)) { |
There was a problem hiding this comment.
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 👍 / 👎.
4533726 to
95b7273
Compare
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 formatpnpm vitest run src/__tests__/client-metro-companion.test.ts src/__tests__/client-metro-companion-worker.test.tspnpm check:unitnode --test test/integration/installed-package-metro.test.ts