Skip to content

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

Description

@connor4312

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/)

Activity

  1. Flarna commented on Nov 29, 2024

    @Flarna
    Member

    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.

  2. added
    windowsIssues and PRs related to the Windows platform.
    pathIssues and PRs related to the path subsystem.
    on Nov 29, 2024
  3. IsmaelCoulibalyPLRM commented on Dec 6, 2024

    @IsmaelCoulibalyPLRM

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

  4. Flarna commented on Dec 6, 2024

    @Flarna
    Member

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

  5. connor4312 commented on Dec 10, 2024

    @connor4312
    ContributorAuthor

    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

  6. added a commit that references this issue on Dec 10, 2024
  7. added a commit that references this issue on Dec 20, 2024
  8. added a commit that references this issue on Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pathIssues and PRs related to the path subsystem.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions