nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
107.91k stars 29.74k forks source link

http.request socketPath doesn't work on Windows #35008

Open sschultze opened 4 years ago

sschultze commented 4 years ago

When calling http.request with the socketPath option on Windows in order to try to connect to a Unix domain socket, I get the following error message:

Error: connect ENOTSOCK C:\Users\User\AppData\Local\Temp\test.sock
    at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)

There is native Unix Domain Sockets support in Windows 10 since two years, and the documentation at https://nodejs.org/api/http.html gives no indication that socketPath doesn't work on Windows, so I guess that this can be considered as an error.

What steps will reproduce the bug?

Call http.request with the socketPath option on Windows. Specify a Unix domain socket path.

lpinca commented 4 years ago

You have to use a named pipe on Windows, see https://nodejs.org/api/net.html#net_ipc_support. AFAIK Node.js does not support UDS on Windows.

lpinca commented 4 years ago

cc: @nodejs/platform-windows @nodejs/net @nodejs/libuv

arixmkii commented 1 year ago

AF_UNIX sockets on Windows were marked GA in build 18362 of Windows 10.

According to this list from MS, the only version, still within the window Mainstream support w/o support is Enterprise/IoT LTSC 1809.

It looks like this could be considered supported for all mainstream Windows versions. Would be nice to have this feature supported as many other languages has this implemented in their runtimes.

bnoordhuis commented 1 year ago

Blocked on https://github.com/libuv/libuv/issues/2537.

ravicious commented 1 year ago

At Teleport we develop a multi-platform Electron app which talks to a local daemon over gRPC. Since Node.js on Windows doesn't support Unix sockets, we use gRPC over TCP with mTLS to keep it secure. See CVE-2022-41924 for a vulnerability which depended on Tailscale running an unsecured HTTP API over TCP vs running the same API over a socket on unixes.

Unix socket support on Windows would mean that we can completely remove the mTLS setup and all ceremonies related to it with a much simpler socket based solution. TCP + mTLS was preferred over named pipes due to another team reportedly having bad time with them on Windows.

bnoordhuis commented 1 year ago

This is basically "pull request welcome" territory although it's intricate and laborious enough that it likely needs (edit: libuv and node) maintainer involvement. Probably a day or two, three of work. Get in touch if you want to sponsor it.