Skip to content

fs: add windowsHandle option to file streams - #63851

Open
PickBas wants to merge 2 commits into
nodejs:mainfrom
JaneaSystems:win-pipe-handle
Open

fs: add windowsHandle option to file streams#63851
PickBas wants to merge 2 commits into
nodejs:mainfrom
JaneaSystems:win-pipe-handle

Conversation

@PickBas

@PickBas PickBas commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

On Windows, a value passed as fd to fs.createReadStream() / fs.createWriteStream() is treated as a CRT file descriptor. When the value is actually a raw Win32 HANDLE, for example an inherited anonymous pipe handle received from another process, it fails with EBADF, since libuv operates on CRT file descriptors.

This adds a windowsHandle option to both stream constructors that wraps the HANDLE in a CRT file descriptor via _open_osfhandle(), so the stream can read from or write to it normally.

Fixes: #57288

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/gyp

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Jun 11, 2026
@PickBas
PickBas marked this pull request as ready for review June 11, 2026 13:53
Comment thread src/node_file.cc Outdated
@PickBas
PickBas requested a review from addaleax June 18, 2026 10:03
@PickBas

PickBas commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

@addaleax Could you please take another look at this PR?

@StefanStojanovic StefanStojanovic added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 14, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 14, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@StefanStojanovic StefanStojanovic added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 21, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 21, 2026
@StefanStojanovic StefanStojanovic added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 22, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 22, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@StefanStojanovic StefanStojanovic added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 28, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 28, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@StefanStojanovic StefanStojanovic added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 3, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 3, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@StefanStojanovic StefanStojanovic added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. and removed commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Aug 4, 2026
Fixes: nodejs#57288
Signed-off-by: PickBas <sayed.kirill@gmail.com>
Signed-off-by: PickBas <sayed.kirill@gmail.com>
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.31%. Comparing base (ee64033) to head (36f2bcd).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/fs/streams.js 91.66% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63851      +/-   ##
==========================================
+ Coverage   90.29%   90.31%   +0.02%     
==========================================
  Files         759      759              
  Lines      247754   247788      +34     
  Branches    46721    46741      +20     
==========================================
+ Hits       223708   223798      +90     
+ Misses      15521    15468      -53     
+ Partials     8525     8522       -3     
Files with missing lines Coverage Δ
src/node_file.cc 74.23% <ø> (-0.04%) ⬇️
lib/internal/fs/streams.js 93.10% <91.66%> (-0.12%) ⬇️

... and 35 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@StefanStojanovic StefanStojanovic added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 6, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 6, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@StefanStojanovic StefanStojanovic added commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. commit-queue Add this label to land a pull request using GitHub Actions. labels Aug 6, 2026
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++. commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows anonymous pipes do not work with createReadStream

4 participants