denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
98.08k stars 5.4k forks source link

Support for Named Pipes in Deno.connect #10244

Open DjDeveloperr opened 3 years ago

DjDeveloperr commented 3 years ago

Why?

Currently, Deno.connect only supports IPC for unix (using unstable transport: "unix"). There should be named pipes support too, which would allow IPC on Windows (as NodeJS' net mode does, it supports both, reference).

Additional info

I have tried using Deno.open but it doesn't work too well here. A native addon to Deno.connect would be way better.

piscisaureus commented 3 years ago
  1. Windows 10 actually supports AF_UNIX; mapping {transport: "unix"} to a named pipe seems less than obvious.
  2. Supporting named pipes on Windows does not automatically mean that Deno supports IPC. In Node.js, "ipc" mode uses a special purpose application-level protocol on top of named pipes (https://github.com/libuv/libuv/blob/47e0c5c575e92a25e0da10fc25b2732942c929f3/src/win/pipe.c#L65-L84).
DjDeveloperr commented 3 years ago

I wasn't aware Windows supports AF_UNIX, but transport: "unix" doesn't seem to work at all in Windows (I'm on Windows 10). I tried it with existent named pipe, file, and a non-existent path, all I got is:

Uncaught TypeError: Error parsing args: data did not match any variant of untagged enum ArgsEnum
    at unwrapOpResult (deno:core/core.js:100:13)
    at Object.opAsync (deno:core/core.js:109:28)
    at Object.opConnect (deno:runtime/js/30_net.js:22:17)
    at Object.connect (deno:runtime/js/40_net_unstable.js:37:29)
    at <anonymous>:2:23

but it shows correct error on WSL when I try to connect:

Uncaught NotFound: No such file or directory (os error 2)
    at unwrapOpResult (deno:core/core.js:100:13)
    at async Object.connect (deno:runtime/js/40_net_unstable.js:37:19)
    at async <anonymous>:2:12
jimboyeah commented 3 years ago

fallback to TCPIP

DjDeveloperr commented 3 years ago

fallback to TCPIP

The application I'm trying to interact with through named pipes does not support that.

lucacasonato commented 3 years ago

Tokio supports named pipes now, so this should be unblocked: https://github.com/tokio-rs/tokio/releases/tag/tokio-1.7.0

DjDeveloperr commented 3 years ago

Tokio supports named pipes now, so this should be unblocked: https://github.com/tokio-rs/tokio/releases/tag/tokio-1.7.0

Would a PR be welcome to add new transport for named pipes? I'm going to give this a try