-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression in fs.readdirSync
on AIX introduced in 18.17.0
#49499
Comments
Looking at the changelog for 18.17.0 I would expect the root cause to be #41439 but my |
If I revert this specific part of the commit diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js
index 23865845ba..7b88ae5574 100644
--- a/lib/internal/fs/utils.js
+++ b/lib/internal/fs/utils.js
@@ -232,7 +231,7 @@ function join(path, name) {
}
if (typeof path === 'string' && typeof name === 'string') {
- return pathModule.basename(path) === name ? path : pathModule.join(path, name);
+ return pathModule.join(path, name);
} Then my issue seems to go away. @Ethan-Arrowood do you recall why this particular change was necessary? The |
Well attempting to run the tests shows that there's probably a pretty good reason that this was introduced! 🙃
|
I introduced that so that recursive readdir would work. I think I remember AIX being a trouble platform to get it to play well. Look and see what's being returned from lower level calls (such as the bindings). There's a good chance AIX is leaving off valuable info about a file and so the code is making a best guess (and getting it wrong) |
I've managed to recreate this issue on macOS/arm64 by forcing the My hunch in #49499 (comment) on the suspicious behaviour in PR #49603 opened with the proposed fix. |
If the libuv operations invoked by `readdir`/`opendir` return `uv_dirent_t` values where the `type` is `UV_DIRENT_UNKNOWN` then a further `lstat` is issued to fully construct the `Dirent` values. In the recursive versions of these functions, the `path` parameter was incorrectly assumed to be the path to the entry when it should be the path to the directory containing the entry. Fixes #49499. PR-URL: #49603 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
If the libuv operations invoked by `readdir`/`opendir` return `uv_dirent_t` values where the `type` is `UV_DIRENT_UNKNOWN` then a further `lstat` is issued to fully construct the `Dirent` values. In the recursive versions of these functions, the `path` parameter was incorrectly assumed to be the path to the entry when it should be the path to the directory containing the entry. Fixes #49499. PR-URL: #49603 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
If the libuv operations invoked by `readdir`/`opendir` return `uv_dirent_t` values where the `type` is `UV_DIRENT_UNKNOWN` then a further `lstat` is issued to fully construct the `Dirent` values. In the recursive versions of these functions, the `path` parameter was incorrectly assumed to be the path to the entry when it should be the path to the directory containing the entry. Fixes nodejs#49499. PR-URL: nodejs#49603 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Version
v18.17.0
Platform
AIX huritmdemo 3 7 00F70A434C00
Subsystem
fs
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
This reproduce is stable and does not depend on the precise name of the file/folder.
What is the expected behavior? Why is that the expected behavior?
The expected behaviour is that the file with the same name as the folder is correctly reported as a file
What do you see instead?
The actual behaviour is that the file with the same name as the folder is incorrectly reported to be a directory
Additional information
No response
The text was updated successfully, but these errors were encountered: