Skip to content

fs.rmSync() cannot remove broken symbolic link #61020

Description

@Yuchen-Dai

Version

v24.12.0

Platform

Microsoft Windows NT 10.0.22631.0 x64

Subsystem

No response

What steps will reproduce the bug?

fs.rmSync() fail to remove broken symlinks.
The same operation works correctly in Node.js 22 and earlier.

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

Everytime
Only happens when:

  1. The symlink target does not exist
  2. Using rmSync (rm works correctly)

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

fs.rmSync() should remove the symlink even if it's broken

What do you see instead?

rmSync fails silently, and the broken symlink remains on disk.

Additional information

Not sure if it is related to #58768

Activity

  1. Renegade334 commented on Dec 11, 2025

    @Renegade334
    Member

    This doesn't appear to be specific to Windows, I can reproduce on Linux in v24.11.1 and v25.2.1 (but not in v22.21.0):

    • if symlink points to a file, then rmSync unlinks it as expected
    • if symlink points to a directory, then rmSync throws ERR_FS_EISDIR (rm works as expected)
    • if symlink points to an invalid path, then rmSync is a no-op but does not throw (rm works as expected)
  2. added
    confirmed-bugIssues and PRs for confirmed bugs.
    fsIssues and PRs related to file-system APIs and the fs module.
    on Dec 11, 2025
  3. added a commit that references this issue on Jan 13, 2026
  4. added a commit that references this issue on Jan 19, 2026
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

    confirmed-bugIssues and PRs for confirmed bugs.fsIssues and PRs related to file-system APIs and the fs module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions