Skip to content
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 opendir function returned an incorrect result. #54315

Closed
magic-akari opened this issue Aug 11, 2024 · 6 comments
Closed

The opendir function returned an incorrect result. #54315

magic-akari opened this issue Aug 11, 2024 · 6 comments
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. fs Issues and PRs related to the fs subsystem / file system.

Comments

@magic-akari
Copy link

magic-akari commented Aug 11, 2024

Version

v20.15.1

Platform

Darwin akari-MacBook-Pro.local 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000 arm64

Subsystem

No response

What steps will reproduce the bug?

opendir-wrong-result-0.0.0.tgz

Download the package and execute the command node list.mjs | wc.

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

Always

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

Should print 465

What do you see instead?

Printed 188

Additional information

Code:

import fs from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";

const data = fileURLToPath(new URL("./test_data", import.meta.url));

const dir = await fs.opendir(data, { recursive: true });
for await (const dirent of dir) {
    if (!dirent.isFile()) {
        continue;
    }
    console.log(path.join(dirent.parentPath, dirent.name));
}

It may be related to the bufferSize.
Adjusting the bufferSize to 500 resulted in the correct output being printed.

- const dir = await fs.opendir(data, { recursive: true });
+ const dir = await fs.opendir(data, { recursive: true, bufferSize: 500 });
@avivkeller avivkeller added the fs Issues and PRs related to the fs subsystem / file system. label Aug 11, 2024
@aduh95
Copy link
Contributor

aduh95 commented Aug 12, 2024

Thanks for filling the issue. If you're able to post a repro that does not involve downloading code from the internet, you're more likely to get help. Ideally, a list of commands that one can copy paste in their terminal.

@sjohannes
Copy link

This seems to be the same as #48820.

@avivkeller
Copy link
Member

This seems to be the same as #48820.

@mdouglass is this the same as the issue you reported?

@juanarbol
Copy link
Member

I think this is more a documentation issue. But not quite sure.

#48820 (comment)

@Ethan-Arrowood
Copy link
Contributor

This is a duplicate of #48820. closing in favor of that one

@Ethan-Arrowood Ethan-Arrowood added the duplicate Issues and PRs that are duplicates of other issues or PRs. label Nov 6, 2024
@aduh95
Copy link
Contributor

aduh95 commented Nov 6, 2024

Duplicate of #48820

@aduh95 aduh95 marked this as a duplicate of #48820 Nov 6, 2024
@aduh95 aduh95 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

No branches or pull requests

6 participants