Skip to content

net: add createPipe() - #65094

Open
kingces95 wants to merge 1 commit into
nodejs:mainfrom
kingces95:create-pipe
Open

net: add createPipe()#65094
kingces95 wants to merge 1 commit into
nodejs:mainfrom
kingces95:create-pipe

Conversation

@kingces95

@kingces95 kingces95 commented Aug 7, 2026

Copy link
Copy Markdown

Adds a node:pipe module with createPipe(), returning a readable
and writable endpoint owned by the parent process.

The endpoints may be passed to child_process.spawn() stdio. This lets
the parent lend a pipe endpoint to a child without turning the parent
stream itself into child-owned stdio. The parent can then reclaim unread
bytes or lend the same endpoint to a later child.

This is useful for bash-like partial consumption of long-lived streams.
For example, a parent can keep ownership of an Server Sent Event stream
while delegating bounded reads to external tools, then continue parsing
from the exact byte where the child stopped.

The central integration test writes abc, lets child A read a, lets
child B read b, and then verifies that the parent can still read c.

Endpoints created by pipe.createPipe() are rejected by spawnSync(), and
an endpoint may only be leased to one child process at a time.

Tests cover node:pipe creation, documentation examples, child stdio
leasing, sequential lease-and-reclaim behavior, lease error cleanup,
spawnSync() rejection, and platform-consistent writable finish
behavior.

Signed-off-by: Chris King <kingces95@gmail.com>
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Aug 7, 2026
@kingces95
kingces95 marked this pull request as ready for review August 7, 2026 01:52
@kingces95 kingces95 changed the title net: add parent-owned pipe endpoints net: add createPipe() Aug 7, 2026
@marco-ippolito

Copy link
Copy Markdown
Member

I dont think we should create a new module

@jasnell

jasnell commented Aug 7, 2026

Copy link
Copy Markdown
Member

+1, there's no justification for a new top-level module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants