Repository navigation
Conversation
YEthYuan
force-pushed
the
codex/heartbeat-bound-port
branch
from
November 13, 2026 08:10
d6b132b to
6e3abe4
Compare
YEthYuan
force-pushed
the
codex/heartbeat-bound-port
branch
from
November 13, 2026 08:16
6e3abe4 to
a4a708b
Compare
YEthYuan
marked this pull request as ready for review
November 13, 2026 08:22
This branch has not been deployed
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 another process claims the heartbeat's candidate port before the heartbeat thread binds it, the existing retry logic selects a replacement port. However,
IPKernelApphas already copied the original port, so it can write a connection file that points clients at the wrong endpoint.Wait for heartbeat binding to complete before copying and logging the port.
Heartbeat.start()now waits for a future completed after successful binding. The ZeroMQ socket is still created, bound, and used on the heartbeat thread;Heartbeat.addris updated after successful binding. Socket setup and exception handling retain their existing implementation.Port conflict before and after this change
Pis the initial candidate port;Qis the replacement selected after a bind conflict. The temporary socket releasesPbefore the actual heartbeat socket binds it.sequenceDiagram participant App as Kernel startup participant OS as Operating system participant Other as Another process participant HB as Heartbeat thread App->>OS: Bind temporary TCP socket to port 0 OS-->>App: Assign port P App->>OS: Close temporary socket Note over App,OS: P is available again Other->>OS: Bind socket with automatic port selection OS-->>Other: Assign and bind P alt Before this change App->>App: Copy candidate P into hb_port App->>HB: Start heartbeat thread HB->>OS: Bind heartbeat socket to P OS-->>HB: Address already in use HB->>OS: Retry binding on port Q OS-->>HB: Binding succeeds App->>App: Write connection file with hb_port P Note over App,HB: Clients receive P but heartbeat listens on Q else With this change App->>HB: Start heartbeat thread and wait for binding HB->>OS: Bind heartbeat socket to P OS-->>HB: Address already in use HB->>OS: Retry binding on port Q OS-->>HB: Binding succeeds HB-->>App: Signal successful binding App->>App: Copy bound port Q into hb_port App->>App: Write connection file with hb_port Q Note over App,HB: Published port matches the bound heartbeat socket end