Skip to content

dirent.isSymbolicLink() returns false for directory symbolic links in Windows #48799

@Bobby-McBobface

Description

@Bobby-McBobface

Version

v18.16.0

Platform

Microsoft Windows NT 10.0.22621.0 x64

Subsystem

node:fs/promises

What steps will reproduce the bug?

  1. Make a directory mkdir foo
  2. Make a directory symlink mklink /D "bar" "foo" - bar is now a symlink to foo.
const fs = require("fs/promises")
for await (const dirent of await fs.opendir('./')) {
 console.log(dirent.name, dirent.isDirectory(), dirent.isSymbolicLink()) 
}

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

Always, on Windows

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

I'd expect the output to be

bar false true
foo true false

Because bar is not a directory, but is a symlink. Therefore, I'd expect bar false true.
It could be argued that bar is actually a directory, so I might also expect bar true true.

For foo, because it is a directory, and not a symlink, I'd expect foo true false.

I'd also expect the same outputs on Linux and Windows.

What do you see instead?

bar true false
foo true false

The outputs says that bar is a directory and not a symlink.
Proof the symlink is created correctly:
image

Additional information

Doesn't reproduce on Ubuntu Linux 22.04 (x86_64 GNU/Linux), or any other Linux system I test it on.

  1. mkdir foo
  2. ln -s ./foo bar

The script outputs

foo true false
bar false true

Which is the expected result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.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