Default the session socket to a named pipe on windows - #7985
Open
denusklo wants to merge 1 commit into
Open
Conversation
The session socket defaults to a path inside the user data directory, which
windows cannot bind: it has no Unix sockets. The bind failure is caught and
warned about, and the server is returned anyway, so startup prints
warn Could not create socket at ...\code-server-ipc.sock
info Session server listening on ...\code-server-ipc.sock
about a socket that does not exist, and nothing listens on it. That socket is
what shouldOpenInExistingInstance consults, so on windows `code-server <file>`
run from a shell can never find a running instance and starts its own server
instead.
Windows has the same facility under a different name, so this defaults to a
named pipe there. The name is derived from the user data directory, so
instances with separate data directories do not collide and a later invocation
with the same one finds the first, and it is case-folded first because windows
compares paths that way and the same directory typed two ways should not
produce two pipes. An explicitly passed --session-socket is untouched on every
platform.
Nothing downstream needed changing: the paths are only ever handed to
net.connect and http.request, both of which take a pipe name on windows, and
listen()'s unlink-first only has to tolerate ENOENT, which it already does.
Measured against a real windows build, one flag apart:
--session-socket '\.\pipe\...' no warning; "Session server listening on"
that pipe; canConnect true; GET /session
answers 200
(default) the warning above, the phantom "listening"
line, and no such file on disk
The helper takes the platform rather than reading process.platform directly,
following getEnvPaths and constructOpenOptions, so both branches are tested
where the tests run.
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.
The session socket defaults to a path inside the user data directory, which
windows cannot bind: it has no Unix sockets. The bind failure is caught and
warned about, and the server is returned anyway, so startup prints
warn Could not create socket at ...\code-server-ipc.sock
info Session server listening on ...\code-server-ipc.sock
about a socket that does not exist, and nothing listens on it. That socket is
what shouldOpenInExistingInstance consults, so on windows
code-server <file>run from a shell can never find a running instance and starts its own server
instead.
Windows has the same facility under a different name, so this defaults to a
named pipe there. The name is derived from the user data directory, so
instances with separate data directories do not collide and a later invocation
with the same one finds the first, and it is case-folded first because windows
compares paths that way and the same directory typed two ways should not
produce two pipes. An explicitly passed --session-socket is untouched on every
platform.
Nothing downstream needed changing: the paths are only ever handed to
net.connect and http.request, both of which take a pipe name on windows, and
listen()'s unlink-first only has to tolerate ENOENT, which it already does.
Measured against a real windows build, one flag apart:
--session-socket '.\pipe...' no warning; "Session server listening on"
that pipe; canConnect true; GET /session
answers 200
(default) the warning above, the phantom "listening"
line, and no such file on disk
The helper takes the platform rather than reading process.platform directly,
following getEnvPaths and constructOpenOptions, so both branches are tested
where the tests run.