Skip to content

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

Merged
davidmckayv merged 3 commits into
CopilotKit:mainfrom
Bartok9:bartok/bot-empty-port-as-unset
Sep 6, 2026
Merged

Read an empty Bot PORT as unset, so NaN never reaches Bun.serve#395
davidmckayv merged 3 commits into
CopilotKit:mainfrom
Bartok9:bartok/bot-empty-port-as-unset

Conversation

@Bartok9

@Bartok9 Bartok9 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

What this changes

PORT= on agent-bot / agent-langgraph used to parse as NaN and Bun.serve bound an ephemeral port while compose still published 4200/4201. Empty now means the shipped default; a non-digit value refuses to start. Same trap as supervisor #343.

Where it runs

  • New state that outlives a request? None.
  • What happens on the second replica? Each process reads its own PORT at boot. No shared state.
  • Anything serialised? No.
  • Anything fanned out to a browser? No.
  • New listener, port, or schedule? No. Existing listen ports only, parsed the same way as the supervisor.

Boundary and audit

  • Every acting call still goes through the gateway: resolve, decide, audit, then act.
  • New refusals and new failures each write a row. Boot refusal is process exit before serve; no new acting path.
  • Nothing new is trusted from the client that the server can resolve itself.

Changelog

  • A line in CHANGELOG.md under Unreleased.

Proof

Shared listenPort tests: empty/whitespace → fallback; digits in range accepted; 42o0 / 0 / 65536 refused.

agent-bot and agent-langgraph still used Number.parseInt(process.env.PORT ?? default).
Empty PORT= is not undefined, so parseInt yielded NaN and Bun.serve bound an ephemeral
port while compose published 4200/4201. Prefix typos started on the numeric prefix.
Same trap as supervisor CopilotKit#343.

@davidmckayv davidmckayv 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.

Deep-reviewed against live code (correctness, governance, no vendor/secret/scale issues). Composed build+tests green. CHANGELOG/format rebase on CI-validated substance.

@davidmckayv
davidmckayv merged commit 35d46e2 into CopilotKit:main Sep 6, 2026
14 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