Skip to content

feat(net): named pipe support via Deno.pipe #29308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

CyanChanges
Copy link
Contributor

@CyanChanges CyanChanges commented May 15, 2025

close #10244

Support Named Pipes via Deno.pipe

todos

@CyanChanges
Copy link
Contributor Author

image

Confirmed!
Works in Windows now!

(I spent a total of $5 on GCP for a Windows machine 😢)

@CyanChanges
Copy link
Contributor Author

Working on the Windows support for the deno_node PipeWrap .
image

@CyanChanges
Copy link
Contributor Author

CyanChanges commented May 19, 2025

Help Wanted

I encountered an issue when working on the node compat:

import * as net from 'node:net'

// I have a server listening on this pipe
// ```ts
// const pipe = Deno.pipe.listen({ path: "\\\\.\\pipe\\mypipe1", kind: "windows", pipeMode: "byte" })
// const ab = new Uint8Array(32)
// await pipe.read(ab); // didn't resolve, it resolve to null after the other side closed :skull: 
// ```
const conn = new net.createConnection({ path: "\\\\.\\pipe\\mypipe1" }) 
conn.write("something") // `true`, but do nothing

// if you await here, it will stuck here
/*await */ Deno[Deno.internal].core.write(
  /* 
  If you createConnection immediately after start, 
  the pipe resource should be assigned a rid of 3
  */ 
  3, 
  new TextEncoder().encode("test")
)

I tried to write it directly via Resource Id, but the promise never resolves,
instead, it rejects after the resource closed 😢

The read still works tho, no idea why.

image

The Problem Only Appear In Windows (Because the issue aim to support node:net.createConnection when using Windows with named pipe)

@nathanwhit nathanwhit added the ci-draft Run the CI on draft PRs. label May 23, 2025
Copy link
Member

@nathanwhit nathanwhit left a comment

Choose a reason for hiding this comment

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

nice, the implementation looks reasonable to me. I'm less sure about the public API changes and the pipe_wrap changes for windows. The pipe_wrap changes seem ok at a glance.

I think the team will have to discuss the new API, and then go from there.

match &mut *inner {
Inner::Server((ref mut connected, server)) => {
if !*connected {
server.connect().await?;
Copy link
Member

Choose a reason for hiding this comment

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

Why wait to connect until read/write is called? I assume it's related to the todo in new_server?

@CyanChanges CyanChanges force-pushed the pipes branch 3 times, most recently from 41c871d to e281862 Compare May 24, 2025 09:44
@bartlomieju bartlomieju added this to the 2.4.0 milestone May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-draft Run the CI on draft PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not implemented: Pipe.prototype.connect Uncaught Error: Not implemented: Pipe.prototype.listen - Windows Support for Named Pipes in Deno.connect
3 participants