Inconsistent behavior between sync and async file deletion methods with specific path patterns.
The issue highlights a discrepancy between `fs.rmSync` and `fs/promises.rm` when handling paths containing `.` and `..`. The sync method succeeds in some cases where the async method fails, indicating inconsistent path resolution logic. The fix likely involves aligning the behavior in the `rimraf` implementation, but requires careful testing to ensure no regressions.
v25.6.1
Darwin moxy.lan 25.3.0 Darwin Kernel Version 25.3.0: Wed Jan 28 20:47:03 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T6031 arm64
lib/internal/fs/rimraf.js
Create a nested folder:
mkdir -p a/b/c/d
Attempt to delete with this weirdly constructed path:
Welcome to Node.js v25.6.1.
Type ".help" for more information.
> await require('fs/promises').rm('a/b/../.', { recursive: true, force: true })
Uncaught [Error: EINVAL: invalid argument, rmdir 'a/b/../.'] {
errno: -22,
code: 'EINVAL',
syscall: 'rmdir',
path: 'a/b/../.'
}
Verify that nothing was removed:
$ tree
./
└── a/
└── b/
└── c/
└── d/
Attempt to delete synchronously:
> require('fs').rmSync('a/b/../.', { recursive: true, force: true })
undefined
It was (mostly?) removed:
$ tree
./
└── a/
The weird thing is that a/b/../. should resolve to just a, so it's weird that it only deletes up to b. It's almost as if the rmSync method is coalescing /../. into just /.
Also, if the . is not the last item, then it seems to be fine? a/b/.././b deletes the b folder, and a/b/.. deletes just b, but not a.
At least, it seems like the sync and asynchronous methods should either both fail, or both succeed, with the same error.
every time, see repro steps above
sync and asynchronous rm methods should fail and succeed in the same way on the same input.
Some cases where rmSync succeeds, and fs/promises.rm fails.
I have a fix that I could land in the upstream rimraf library, and I'd of course be happy to send a PR to node to bring it back into alignment, since there have also been some improvements in performance and Windows re
Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!