fix(events): claim the IPC endpoint atomically before removing stale sockets (#209 follow-up) - #216
Conversation
…sockets (#209 follow-up)
🦋 Changeset detectedLatest commit: 4c68b51 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4c68b51c1b
ℹ️ 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".
Summary
Addresses the unresolved P1 Codex finding on #209 (
ipc.ts:287): two concurrently starting runtime processes could both observe a stale endpoint; after the first removed it and bound, the second's unconditionalrm(endpoint)unlinked the first's LIVE socket, leaving a running but unreachable server.Stale cleanup is now guarded by an atomic endpoint claim:
<endpoint>.lock,open('wx')) serializes competing servers; the stalermand the bind happen only while holding the claim, after a re-probe under the lock (a re-probedliveendpoint fails with the existing live-server error instead of being removed).removeOwnedEndpoint. The win32 path (no unix sockets) is untouched.A test-only seam (
createEventRuntimeServerForTestwith anafterEndpointProbehook) makes the race deterministic.Tests
does not unlink a concurrent winner after both servers probe a stale endpoint— freezes both racers in the historical probe-then-unlink window, lets one win, then asserts the loser fails with the live-server error and the winner still serves requests over its original socket.Gates: scoped rstest (event-ipc),
pnpm typecheck,pnpm lint, fullpnpm build— all green.