Skip to content
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

Node 23.2 fs lost the ability to enumerate named pipes on Windows #56002

Closed
connor4312 opened this issue Nov 26, 2024 · 4 comments · Fixed by #56110
Closed

Node 23.2 fs lost the ability to enumerate named pipes on Windows #56002

connor4312 opened this issue Nov 26, 2024 · 4 comments · Fixed by #56110
Labels
path Issues and PRs related to the path subsystem. windows Issues and PRs related to the Windows platform.

Comments

@connor4312
Copy link
Contributor

Version

23.2.0

Platform

Microsoft Windows NT 10.0.22631.0 x64

Subsystem

fs

What steps will reproduce the bug?

This regressed in 23.2:

PS C:\Users\conno> fnm use 23.1
Using Node v23.1.0
PS C:\Users\conno> node
Welcome to Node.js v23.1.0.
Type ".help" for more information.
> fs.readdirSync('\\\\.\\pipe').length
510

PS C:\Users\conno> fnm use 23.2
Using Node v23.2.0
PS C:\Users\conno> node
Welcome to Node.js v23.2.0.
Type ".help" for more information.
> fs.readdirSync('\\\\.\\pipe').length
Uncaught Error: ENOTDIR: not a directory, scandir '\\.\pipe'
    at Object.readdirSync (node:fs:1499:26) {
  errno: -4052,
  code: 'ENOTDIR',
  syscall: 'scandir',
  path: '\\\\.\\pipe'
}

How often does it reproduce? Is there a required condition?

100%

What is the expected behavior? Why is that the expected behavior?

The contents of \\.\pipe should be able to be read as a directory.

What do you see instead?

ENOTDIR when enumerating \\.\pipe

Additional information

This causes js-debug's debugger to break #55948. There is not really a good workaround.

Windows lacks any kind of API aside from this for checking the existence of a named pipe--as exists / stat actually connects to the pipe--so listing \\.\pipe is a common pattern for Windows applications who need to check (e.g. https://berserkerdotnet.github.io/blog/detecting-namedpipe-exists/)

@Flarna
Copy link
Member

Flarna commented Nov 29, 2024

bisect a bit on 23 branch and found that commit 038ac01 seems to cause this.
The corresponding commit on main is 7f68e54 from PR #55623.

The diff introduced with above commit is that node:ToNamespacedPath() appended \ before, after the commit it doesn't.
\\\\.\\pipe\\ - works
\\\\.\\pipe - fails

@huseyinacacak-janea any hints how to fix this.

@Flarna Flarna added windows Issues and PRs related to the Windows platform. path Issues and PRs related to the path subsystem. labels Nov 29, 2024
@IsmaelCoulibalyPLRM
Copy link

hello @Flarna , when will the fix be available so that I can update node and avoid the debugging problem ?

@Flarna
Copy link
Member

Flarna commented Dec 6, 2024

Fix PR is waiting on more approvals.
Next 23 release is planned for 17.12.

nodejs-github-bot pushed a commit that referenced this issue Dec 10, 2024
PR-URL: #56110
Fixes: #56002
Refs: #55623
Refs: #56088
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@connor4312
Copy link
Contributor Author

connor4312 commented Dec 10, 2024

Thanks for the fix!

For the release notes it would probably worth it to mention readdirSync('\\\\.\\pipe') failing (requiring a trailing slash) as a breaking change for others

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
path Issues and PRs related to the path subsystem. windows Issues and PRs related to the Windows platform.
Projects
None yet
3 participants