Skip to content

fix(desktop): give isolated dev service a fixed port - #52013

Merged
Hona merged 1 commit into
anomalyco:v2from
Hona:desktop-dev-port
Sep 29, 2026
Merged

Hona merged 1 commit into
anomalyco:v2from
Hona:desktop-dev-port

Conversation

@Hona

@Hona Hona commented Sep 29, 2026

Copy link
Copy Markdown
Member

Desktop dev (OPENCODE_DESKTOP_ISOLATED_SERVER=1) now starts its service on 0x0C0C (3084, "OC OC") instead of --port 0.

Port Used by
0xC0DE (49374) prod / dev / beta / next
0xC0DF (49375) local channel TUI / CLI
0x0C0C (3084) desktop dev

Why

Service.ensure() relies on the port as the single-instance lock: a second contender hits EADDRINUSE, recognizes the incumbent, and exits. Port 0 never collides, so two services can boot against the same opencode-local.db, and one dies with SQLiteError: database is locked:

sequenceDiagram
  participant D as Desktop ensure()
  participant A as serve --service (A)
  participant B as serve --service (B)
  D->>A: spawn
  Note over A: cold start > 5 s
  D->>B: spawn lock probe
  A->>A: bind :random ✅
  B->>B: bind :random ✅ (no collision)
  A--xA: boot: database is locked
  D--xD: "Background service failed to start"
Loading

Seen 13 times in one local log since 2026-08-21. Every occurrence had two serve --service --port 0 processes running at once: 5 started ~5 s apart (lock probe), 8 started within 3 ms of each other.

With a fixed port, the loser takes the existing path in packages/cli/src/server-process.ts: Service.incumbent / recognizeIncumbent → exit.

  • 3084 is outside the Windows ephemeral range (49152–65535), so the OS doesn't hand it out to outgoing connections.

@Hona
Hona requested a review from Brendonovich as a code owner September 29, 2026 05:06
Copilot AI balanced review requested due to automatic review settings September 29, 2026 05:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Hona
Hona merged commit ff72659 into anomalyco:v2 Sep 29, 2026
10 checks passed
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.

2 participants