Skip to content

fix(frontdoor): retry preferred port on bind and check log existence with stat - #512

Merged
Mearman merged 1 commit into
mainfrom
fix/frontdoor-port-retry-and-log-stat
Oct 18, 2026
Merged

Mearman merged 1 commit into
mainfrom
fix/frontdoor-port-retry-and-log-stat

Conversation

@Mearman

@Mearman Mearman commented Oct 18, 2026

Copy link
Copy Markdown
Member

When a supervisor process restarts or is replaced, the outgoing process
releases its listening ports over a brief window while shutting down its
servers. Previously, listenFrontDoor made only a single bind attempt on
preferredPort; if the socket was still in TIME_WAIT or closing, it
immediately fell back to port 0 (an ephemeral port). This changed the
sticky ports in state.json and severed all running Claude Code child
sessions whose HTTPS_PROXY pointed to the former port.

listenFrontDoor now retries binding preferredPort with a short backoff
window (up to 250ms) before falling back to an ephemeral port, giving the
releasing supervisor time to free the address and preserving port stickiness.

Additionally, collectHeadroomStatus, collectFrontDoorStatus, and
collectCodexStatus checked logExists by reading the entire log file as a
UTF-8 string into memory. Once a log file (such as headroom.log) grew
past Node's 512MB V8 string length limit, readFileUtf8 threw
ERR_STRING_TOO_LONG (0x1fffffe8), crashing status and doctor commands.
HeadroomFs now includes lstat, and logExists uses lstat to verify
existence without allocating memory.

…with stat

When a supervisor process restarts or is replaced, the outgoing process
releases its listening ports over a brief window while shutting down its
servers. Previously, listenFrontDoor made only a single bind attempt on
preferredPort; if the socket was still in TIME_WAIT or closing, it
immediately fell back to port 0 (an ephemeral port). This changed the
sticky ports in state.json and severed all running Claude Code child
sessions whose HTTPS_PROXY pointed to the former port.

listenFrontDoor now retries binding preferredPort with a short backoff
window (up to 250ms) before falling back to an ephemeral port, giving the
releasing supervisor time to free the address and preserving port stickiness.

Additionally, collectHeadroomStatus, collectFrontDoorStatus, and
collectCodexStatus checked logExists by reading the entire log file as a
UTF-8 string into memory. Once a log file (such as headroom.log) grew
past Node's 512MB V8 string length limit, readFileUtf8 threw
ERR_STRING_TOO_LONG (0x1fffffe8), crashing status and doctor commands.
HeadroomFs now includes lstat, and logExists uses lstat to verify
existence without allocating memory.
@Mearman
Mearman merged commit 7f27a9b into main Oct 18, 2026
6 checks passed
@Mearman
Mearman deleted the fix/frontdoor-port-retry-and-log-stat branch October 18, 2026 14:52
@ExaDev ExaDev deleted a comment from chatgpt-codex-connector Bot Oct 19, 2026
@ExaDev ExaDev deleted a comment from chatgpt-codex-connector Bot Oct 19, 2026
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