fs: fix existsSync for invalid symlink at win32 by pd4d10 · Pull Request #30556 · nodejs/node
Fixes: #30538
Background
#18618 uses access instead of stat to implement fs.existsSync. Unfortunately, seems the two approaches both have some limitations at Windows:
Expected behavior of existsSync |
stat |
access |
|
|---|---|---|---|
| Invalid symlink | false |
✅ | |
| File without privileges | true |
✅ |
This PR adds a double check only at win32 platform to fix this issue.
Checklist
-
make -j4 test(UNIX), orvcbuild test(Windows) passes - tests and/or benchmarks are included
- commit message follows commit guidelines