Skip to content

fix(runtime): serialize local Rivet Engine port selection across processes - #76

Merged
eersnington merged 1 commit into
mainfrom
fix/engine-port-collision-retry
Nov 24, 2026
Merged

eersnington merged 1 commit into
mainfrom
fix/engine-port-collision-retry

Conversation

@eersnington

Copy link
Copy Markdown
Member

Makes parallel orange dev processes pick their local Rivet Engine ports one at a time, so one Engine can no longer bind a port another just checked.

  • Every Orange process takes $TMPDIR/open-orange/engine-ports.lock from the port check until its Engine's guard, peer and metrics ports accept connections. The gap was about a second. In it, a parallel Engine could take a port: on the peer port the Engine exits with Address in use (the e2e / durable-objects failure on fix(worker-loader): match workerd for env stubs, module names, stub shape #71), and on the guard port orange dev hangs or reaches the other project's Engine.
  • The per-project start lock and this lock share one lock-file helper. A lock whose holder died is taken over, and the lock file now gets the pid through a hard link, so it is never empty. The machine lock gives up after 120 s with an error naming the lock path and the holder pid.
  • An Engine still gets its previous port first, so its JWT signing keys stay valid.

Proof: tests/cli/orange-dev-engine-port.test.ts starts two projects whose Engines want the same port at once. It failed 3 of 6 runs without the fix and passed 4 of 4 with it.

@eersnington
eersnington force-pushed the fix/engine-port-collision-retry branch from a5fb815 to 6893563 Compare November 24, 2026 21:39
@eersnington
eersnington merged commit f4b7307 into main Nov 24, 2026
12 checks passed
@eersnington
eersnington deleted the fix/engine-port-collision-retry branch November 24, 2026 22:33
@github-actions

Copy link
Copy Markdown

Preview removed; R2 assets deleted.

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