-
-
Notifications
You must be signed in to change notification settings - Fork 257
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
The ‘recursive’ option for FileSystem.readDirectory does nothing on Node 18 #1801
Comments
Ran into this issue too. Adding |
I use this for the time being, seems to work but obviously is suboptimal and inefficient: const readdirRecursive = (
/** Directory to list. */
dir: string,
/**
* Directory to output paths relative to.
* (Don’t specify, used for recursion.)
*/
relativeTo?: string,
):
Effect.Effect<FileSystem.FileSystem, PlatformError, readonly string[]> =>
Effect.gen(function * (_) {
const fs = yield * _(FileSystem.FileSystem);
const dirEntries = yield * _(
fs.readDirectory(dir),
Effect.map(basenames => basenames.map(name => join(dir, name))),
);
const dirEntryStats:
Record<string, FileSystem.File.Info> =
yield * _(Effect.reduceEffect(
dirEntries.map(path => pipe(
fs.stat(path),
Effect.map(stat => ({ [path]: stat })),
)),
Effect.succeed({}),
(accum, item) => ({ ...accum, ...item }),
{ concurrency: 10 },
));
const recursiveListings = dirEntries.map(path =>
dirEntryStats[path]?.type === 'Directory'
? readdirRecursive(path, relativeTo ?? dir)
: Effect.succeed([relative(relativeTo ?? dir, path)])
);
const entries = yield * _(
Effect.all(recursiveListings, { concurrency: 10 }),
Effect.map(resultLists => resultLists.flat()),
);
return entries;
}); |
got the same issue with node 18.15, updated to node 18.19 and it fixed the issue :) You don't need to update to node 20 :) latest version of node 18 are fine. |
- `fs.readdir' func in node version 18.18.2 has buggy `recursive' option See nodejs/node#48640, Effect-TS/effect#1801 for details - We were recursing down a folder in two ways on the Desktop app. Remove `recursive: True' option to the `fs.readdirSync' method call to recurse down via app code only
- `fs.readdir' func in node version 18.18.2 has buggy `recursive' option See nodejs/node#48640, Effect-TS/effect#1801 for details - We were recursing down a folder in two ways on the Desktop app. Remove `recursive: True' option to the `fs.readdirSync' method call to recurse down via app code only
- `fs.readdir' func in node version 18.18.2 has buggy `recursive' option See nodejs/node#48640, Effect-TS/effect#1801 for details - We were recursing down a folder in two ways on the Desktop app. Remove `recursive: True' option to the `fs.readdirSync' method call to recurse down via app code only
What version of Effect is running?
2.0.0-next.62
What steps can reproduce the bug?
Attempt using
fs.readDirectory()
withrecursive
option on a directory with nested directories and files.What is the expected behavior?
The listing is recursive, or the option is not listed in docs in the first place.
What do you see instead?
The resulting listing is not recursive and no error is thrown, neither at compile nor at run time.
Additional information
To be clear, from my tests this is the same with vanilla Node 18’s
fs.readdir()
. I.e., it appears to be either a bug or misdocumentation in Node (I wonder if in this issue someone fat-finger added option in docs of older Node version where it is not supported). However, since this package appears to “proxy” Node docs the deficiency applies here as well.I guess either:
The text was updated successfully, but these errors were encountered: