GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs: readDir {withFileTypes: true} could call callback more than once · Issue #22778 · nodejs/node

fs: readDir {withFileTypes: true} could call callback more than once #22778

New issue
Copy link
New issue
Copy link
Closed
Closed
fs: readDir {withFileTypes: true} could call callback more than once#22778
Copy link
Labels
fsIssues and PRs related to file-system APIs and the fs module.

Description

@ajafff
ajafff
opened on Sep 9, 2018
Issue body actions
  • Version: 10.10.0
  • Platform:
  • Subsystem: fs

While looking through the code of readDir's new option withFileTypes I noticed that getDirents unconditionally calls the callback in case of an error:

node/lib/internal/fs/utils.js

Lines 133 to 136 in d994e26

if (err) {
callback(err);
return;
}

If more than one file is of type UV_DIRENT_UNKNOWN and fs.stat returns with an error for more than one of these files, the callback will be called more than once. That could lead to unexpected behavior for API users.

I don't know if that needs to be fixed as the scenario seems very unlikely, but I thought I should at least report it.

Activity

  1. addaleax
    added
    fsIssues and PRs related to file-system APIs and the fs module.
    on Sep 11, 2018
  2. danbev
    closed this as completedin 466cda0on Sep 13, 2018
  3. targos
    added 3 commits that reference this issue on Sep 15, 2018

    fs: ensure readdir() callback is only called once

    4159000

    fs: ensure readdir() callback is only called once

    e9b5c34

    fs: ensure readdir() callback is only called once

    f0a4017
  4. sjarmak
    added a commit that references this issue on Jul 27, 2026

    fs: ensure readdir() callback is only called once

    466cda0
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

    fsIssues and PRs related to file-system APIs and the fs module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.