GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs: add windowsHandle option to file streams by PickBas · Pull Request #63851 · nodejs/node

Conversation

@PickBas

@PickBas PickBas commented Jun 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nodejs-github-bot

nodejs-github-bot commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/gyp
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@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 file-system APIs and the fs module. needs-ci PRs that need a full CI run. labels Jun 11, 2026
@PickBas
PickBas force-pushed the win-pipe-handle branch from 61e49c9 to 0067917 Compare June 11, 2026 13:50
@PickBas
PickBas marked this pull request as ready for review June 11, 2026 13:53
addaleax
addaleax reviewed Jun 11, 2026
View reviewed changes
Comment thread src/node_file.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

@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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PickBas PickBas mentioned this pull request Jul 1, 2026
win,unix: add uv_pipe_open_ex libuv/libuv#5160
Closed
StefanStojanovic
StefanStojanovic approved these changes Jul 14, 2026
View reviewed changes
@StefanStojanovic StefanStojanovic added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jul 14, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jul 14, 2026
@nodejs-github-bot

nodejs-github-bot commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/74815/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/74844/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

nodejs-github-bot commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/75006/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/75041/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@giroletm giroletm mentioned this pull request Jul 25, 2026
Windows anonymous pipes do not work with createReadStream #57288
Closed
@nodejs-github-bot

nodejs-github-bot commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/75196/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sxa sxa mentioned this pull request Jul 27, 2026
node-test-commit-linux on 'ubuntu2404-x64' is failing since 2026-07-20 nodejs/build#4401
Closed
@nodejs-github-bot

nodejs-github-bot commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/75244/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

nodejs-github-bot commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/75248/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

nodejs-github-bot commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/75422/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/75462/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@StefanStojanovic StefanStojanovic added commit-queue PRs queued for automated landing through the Commit Queue. commit-queue-squash PRs the Commit Queue should land as one squashed commit. and removed commit-queue PRs queued for automated landing through the Commit Queue. commit-queue-squash PRs the Commit Queue should land as one squashed commit. labels Aug 4, 2026
@PickBas
fs: add windowsHandle option to file streams
329b98f
Fixes: nodejs#57288
Signed-off-by: PickBas <[email protected]>
@PickBas
PickBas force-pushed the win-pipe-handle branch from 32c7076 to a40b758 Compare August 6, 2026 11:35
@PickBas
fs: use bigint for windowsHandle option
36f2bcd
Signed-off-by: PickBas <[email protected]>
@PickBas
PickBas force-pushed the win-pipe-handle branch from a40b758 to 36f2bcd Compare August 6, 2026 11:45
@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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

StefanStojanovic
StefanStojanovic approved these changes Aug 6, 2026
View reviewed changes
@StefanStojanovic StefanStojanovic added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Aug 6, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Aug 6, 2026
@nodejs-github-bot

nodejs-github-bot commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/75572/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@StefanStojanovic StefanStojanovic added commit-queue-squash PRs the Commit Queue should land as one squashed commit. commit-queue PRs queued for automated landing through the Commit Queue. labels Aug 6, 2026
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 6, 2026
@nodejs-github-bot
nodejs-github-bot merged commit d9d4446 into nodejs:main Aug 6, 2026
67 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Landed in d9d4446

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aduh95 pushed a commit that referenced this pull request Aug 13, 2026
@PickBas @aduh95
fs: add windowsHandle option to file streams
8a36243
Fixes: #57288
Signed-off-by: PickBas <[email protected]>
PR-URL: #63851
Reviewed-By: Stefan Stojanovic <[email protected]>
aduh95 pushed a commit that referenced this pull request Aug 25, 2026
@PickBas @aduh95
fs: add windowsHandle option to file streams
656cfae
Fixes: #57288
Signed-off-by: PickBas <[email protected]>
PR-URL: #63851
Reviewed-By: Stefan Stojanovic <[email protected]>
@github-actions github-actions Bot mentioned this pull request Aug 25, 2026
2026-08-26, Version 26.8.0 (Current) #65551
Merged
aduh95 pushed a commit that referenced this pull request Aug 27, 2026
@PickBas @aduh95
fs: add windowsHandle option to file streams
212fe77
Fixes: #57288
Signed-off-by: PickBas <[email protected]>
PR-URL: #63851
Reviewed-By: Stefan Stojanovic <[email protected]>
@github-actions github-actions Bot mentioned this pull request Sep 7, 2026
2026-09-08, Version 24.21.0 'Krypton' (LTS) #65873
Merged
@bbonaby bbonaby mentioned this pull request Sep 19, 2026
[Proposal] Use native stdio streams in the Node SDK microsoft/mxc#1220
Closed
3 of 8 tasks
@ig-ant ig-ant mentioned this pull request Oct 27, 2026
fs: add windowsHandle option to file streams oven-sh/bun#47087
Merged
dylan-conway added a commit to oven-sh/bun that referenced this pull request Oct 29, 2026
@ig-ant @autofix-ci @dylan-conway
fs: add windowsHandle option to file streams (#47087)
73a2043
### What does this PR do?

Adds the `windowsHandle` option to `fs.createReadStream` and
`fs.createWriteStream`, so a raw Win32 `HANDLE` can back a file stream,
as in Node 24.21 and 26.8 (nodejs/node#63851).

Bun ignored the option. With an empty path, the stream resolved the
current directory and failed with `EISDIR`.

- `streams.ts` validates the option in Node's check order.
- A small native binding wraps the handle with `uv_open_osfhandle`. The
stream then owns the fd and closes it.
- `bun-types` declares the option, because `@types/node` does not have
it yet.

It also fixes two related problems with fd 0:

- Destroying a file stream skipped the close when its fd was 0. It now
checks `fd == null`, as Node does since nodejs/node#66131, and Node's
updated `test-fs-stream-fs-options.js` is ported. A `windowsHandle` can
be wrapped as fd 0 if the process has closed its stdin.
- Bun destroys `process.stdin` after `'end'`. With the change above,
that would have closed the process's real stdin, so `process.stdin` now
keeps fd 0 open when it is destroyed. A test in `process-stdin.test.ts`
covers this.

One deliberate difference: the handle is wrapped after `start`/`end`
validation, so a failure there leaves the caller owning it. Node wraps
first and leaks the fd in that case. An invalid `highWaterMark` or
`signal` still leaks it, as in Node.

No docs change: Bun's docs do not describe `node:fs` stream options.

### How did you verify your code works?

- Buildkite build #133777 passed on every platform. Both new test files
ran on Windows x64 (Server 2019) and Windows 11 arm64:
`test/js/node/fs/fs-stream-windows-handle.test.ts` and the ported
`test/js/node/test/parallel/test-fs-stream-windows-handle.js`.
- On an unpatched Bun, the ported Node test fails at its first assertion
and the `EISDIR` reproduces.
- On an unpatched Bun, the ported fd 0 test fails, as expected.
- The type fixture in `test/integration/bun-types/fixture/fs.ts` accepts
a `bigint` and rejects a number.

Not yet measured: a pending pipe read holds a libuv threadpool worker,
which may matter with several streams open at once. Node has the same
design.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dylan Conway <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@StefanStojanovic StefanStojanovic StefanStojanovic approved these changes
@addaleax addaleax Awaiting requested review from addaleax

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash PRs the Commit Queue should land as one squashed commit. fs Issues and PRs related to file-system APIs and the fs module. needs-ci PRs that need a full CI run.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Windows anonymous pipes do not work with createReadStream

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@PickBas @nodejs-github-bot @addaleax @StefanStojanovic
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.