Skip to content

Fix --socket-fd with systemd socket activation - #8083

Merged
code-asher merged 1 commit into
coder:mainfrom
acpiper:fix-socket-fd
Oct 28, 2026
Merged

code-asher merged 1 commit into
coder:mainfrom
acpiper:fix-socket-fd

Conversation

@acpiper

@acpiper acpiper commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Fixes #8082

  • Pass the --socket-fd socket from the parent process to the child process. The child calls listen, but it did not inherit the socket. The child gets the socket as fd 4, because fd 3 is the IPC channel.
  • Make ensureAddress return fd:<n> for a Unix socket from --socket-fd. Node returns no address for such a socket, so code-server exited with Server has no address.
  • Add 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 /healthz returns 200. Both cases fail on 4.143.1 with listen EEXIST.
  • Add a test for ensureAddress with a socket fd to test/unit/node/app.test.ts.
  • Add a changelog entry under "Unreleased".

I tested the same change with systemd-socket-activate on Ubuntu 24.04 arm64 and Rocky Linux 9 amd64, applied to the 4.134.0 release build. /healthz returned 200 for TCP and Unix sockets.

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.
@acpiper
acpiper requested a review from a team as a code owner October 28, 2026 00:03

@code-asher code-asher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Wonderfully thorough.

@code-asher
code-asher merged commit 2780846 into coder:main Oct 28, 2026
10 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.

Make --socket-fd work with systemd socket activation

2 participants