Skip to content

Read an empty supervisor PORT as unset, so NaN never reaches Bun.serve - #343

Open
Bartok9 wants to merge 1 commit into
CopilotKit:mainfrom
Bartok9:bartok/supervisor-empty-port-as-unset
Open

Read an empty supervisor PORT as unset, so NaN never reaches Bun.serve#343
Bartok9 wants to merge 1 commit into
CopilotKit:mainfrom
Bartok9:bartok/supervisor-empty-port-as-unset

Conversation

@Bartok9

@Bartok9 Bartok9 commented Sep 2, 2026

Copy link
Copy Markdown

What this changes

The supervisor read Number.parseInt(process.env.PORT ?? "4300", 10). ?? only fires on undefined. An empty PORT= from compose or a leftover .env line is "", so parse became NaN and Bun.serve({ port: NaN }) bound an ephemeral port while compose still published 4300 — the same empty-string trap the API server fixed in #312/#340 and the computer saw in #96/#114. Prefix typos like 30o0 also started on port 30 via parseInt.

Empty/whitespace now means the default 4300. Non-numeric or out-of-range values refuse boot with a clear message. Parser lives in supervisor/src/listen-port.ts with unit tests (no Docker).

Where it runs

  • New state that outlives a request? None. Boot-time number.
  • What happens on the second replica? Each supervisor reads its own env; empty still means 4300 on that process.
  • Anything serialised? No.
  • Anything fanned out to a browser? No.
  • New listener, port, or schedule? No — same listener, correct bind address.

Boundary and audit

  • Every acting call still goes through the gateway: untouched.
  • New refusals and new failures each write a row: boot refusal exits before DB; same shape as missing SUPERVISOR_TOKEN.
  • Nothing new is trusted from the client.

Changelog

  • Unreleased section: empty supervisor PORT is unset, not an ephemeral bind.

Proof

Node smoke of listenPort (empty → 4300; 4500 → 4500; 30o0/0/65536 refused). Added supervisor/tests/listen-port.test.ts for bun test.

Empty PORT= used to parse to NaN and bind an ephemeral port while compose
still published 4300. Treat blank as the default 4300; refuse non-numeric
and out-of-range values instead of parseInt prefix traps.
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