Repository navigation
fix(frontdoor): retry preferred port on bind and check log existence with stat - #512
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.