镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Support bufferSize option with recursive mode in fs.opendir #55764

Description

@Ethan-Arrowood

Related to: #48820 and #55744

After the recursive option was added to readdir and opendir, it was noted that when specifying bufferSize alongside recursive: true, the result of opendir was incorrect. This is fixed in #55744 . However, the fix is a naive solution, and doesn't properly respect the bufferSize option. Furthermore, it could result in a blocked event loop. This should be fixed.

I recommend reading the discussion in #48820 for more information. This should only involve changes to the Dir class in lib/internal/fs/dir.js.

Activity

  1. added
    confirmed-bugIssues and PRs for confirmed bugs.
    fsIssues and PRs related to file-system APIs and the fs module.
    good first issueIssues that are suitable for first-time contributors.
    on Nov 7, 2024
  2. Ethan-Arrowood commented on Nov 7, 2024

    @Ethan-Arrowood
    ContributorAuthor

    If someone would like to submit a fix here, I'm happy to help you land the contribution. Otherwise, I'll work on it eventually.

  3. 0hmX commented on Nov 7, 2024

    @0hmX
    Contributor

    Hey I would love to work on this!

  4. Ethan-Arrowood commented on Nov 7, 2024

    @Ethan-Arrowood
    ContributorAuthor

    Awesome! Feel free to request my review on your PR. I'll keep track of notifications here as well. Reach out to me in the OpenJS Slack if you have any questions

  5. mertcanaltin commented on Nov 8, 2024

    @mertcanaltin
    Member

    I'm here if you need help

  6. KunalKumar-1 commented on Nov 8, 2024

    @KunalKumar-1
    Contributor

    @Ethan-Arrowood Can you clarify what further changes is needed in lib/internal/fs/dir.js ?
    seems you made some changes there already

  7. 0hmX commented on Nov 8, 2024

    @0hmX
    Contributor

    @KunalKumar-1 from what i saw its was a temporary patch to get around the problem. probably have to rewrite this.

  8. Ethan-Arrowood commented on Nov 8, 2024

    @Ethan-Arrowood
    ContributorAuthor

    Yes, the changes I added does not actually respect the bufferSize option, but it at least will return the full contents of a directory. The change I'm requesting here is that we figure out how to properly support bufferSize option.

    My loose idea for a solution would be to add a new queue to the Dir class, something like #handlers, and as things are read, if its in recursive mode, and the current item is a directory, create a handle for that directory, do the read operation (while respecting bufferSize), and if there is more to be read, push that handle to #handlers, and on subsequent reads, make sure to fully read that handler.

  9. KunalKumar-1 commented on Nov 8, 2024

    @KunalKumar-1
    Contributor

    Yes, the changes I added does not actually respect the bufferSize option, but it at least will return the full contents of a directory. The change I'm requesting here is that we figure out how to properly support bufferSize option.

    My loose idea for a solution would be to add a new queue to the Dir class, something like #handlers, and as things are read, if its in recursive mode, and the current item is a directory, create a handle for that directory, do the read operation (while respecting bufferSize), and if there is more to be read, push that handle to #handlers, and on subsequent reads, make sure to fully read that handler.

    Now I understood the issue clearly
    thanks @Ethan-Arrowood for the explanation.
    i have started working on this issue

  10. 0hmX commented on Nov 8, 2024

    @0hmX
    Contributor

    @KunalKumar-1 cool but i was working on this!

  11. 0hmX commented on Nov 13, 2024

    @0hmX
    Contributor

    I will be doping this issue, as I was unable to coming with any good solution for this, you can see the draft PR, if you want to know my approach! Ya! that will be it!

  12. amansharma612 commented on Nov 14, 2024

    @amansharma612

    I would like to take up this issue

  13. 0hmX commented on Nov 29, 2024

    @0hmX
    Contributor

    @Ethan-Arrowood, it’s been two weeks since I opened this PR #55896 When you have some time, could you please take a look?

  14. babyitachi commented on Dec 7, 2024

    @babyitachi

    Hey, I would like to pick this up if not done. Let me know.

  15. Ethan-Arrowood commented on Oct 24, 2025

    @Ethan-Arrowood
    ContributorAuthor

    Closed by #55896

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.fsIssues and PRs related to file-system APIs and the fs module.good first issueIssues that are suitable for first-time contributors.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions