Repository navigation
Fix --socket-fd with systemd socket activation - #8083
Merged
Merged
Conversation
The --socket-fd flag never worked. The wrapper forks the process that listens, but only the IPC channel was inherited as fd 3, so the socket passed by the caller was not available to the child. Node then tried to listen on the IPC pipe and failed with "listen EEXIST". Pass the socket to the child as stdio entry 4 and tell the child to use that fd in the handshake. Node also reports no address for a Unix socket adopted by fd, which made startup fail with "Server has no address". Log the listener as fd:<n> in that case. Add an integration test that starts the code-server binary with a Unix or TCP socket as fd 3 and checks that /healthz answers over it.
code-asher
approved these changes
Oct 28, 2026
code-asher
left a comment
Member
There was a problem hiding this comment.
Thank you! Wonderfully thorough.
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.
Fixes #8082
--socket-fdsocket from the parent process to the child process. The child callslisten, but it did not inherit the socket. The child gets the socket as fd 4, because fd 3 is the IPC channel.ensureAddressreturnfd:<n>for a Unix socket from--socket-fd. Node returns no address for such a socket, so code-server exited withServer has no address.test/integration/socketFd.test.ts. It starts the code-server binary with a Unix socket and with a TCP socket as fd 3, and checks that/healthzreturns 200. Both cases fail on 4.143.1 withlisten EEXIST.ensureAddresswith a socket fd totest/unit/node/app.test.ts.I tested the same change with
systemd-socket-activateon Ubuntu 24.04 arm64 and Rocky Linux 9 amd64, applied to the 4.134.0 release build./healthzreturned 200 for TCP and Unix sockets.