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

lib: fix fs.readdir recursive async #56041

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

RafaelGSS
Copy link
Member

@RafaelGSS RafaelGSS commented Nov 27, 2024

@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Nov 27, 2024
Copy link

codecov bot commented Nov 27, 2024

Codecov Report

Attention: Patch coverage is 43.85965% with 64 lines in your changes missing coverage. Please review.

Project coverage is 87.92%. Comparing base (ce346b6) to head (6ca4cf4).
Report is 35 commits behind head on main.

Files with missing lines Patch % Lines
lib/fs.js 43.85% 64 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #56041      +/-   ##
==========================================
- Coverage   88.00%   87.92%   -0.09%     
==========================================
  Files         653      656       +3     
  Lines      188093   189063     +970     
  Branches    35942    35983      +41     
==========================================
+ Hits       165537   166235     +698     
- Misses      15734    15987     +253     
- Partials     6822     6841      +19     
Files with missing lines Coverage Δ
lib/fs.js 91.45% <43.85%> (-1.91%) ⬇️

... and 43 files with indirect coverage changes

@RafaelGSS RafaelGSS added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 27, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 27, 2024
@nodejs-github-bot
Copy link
Collaborator

}
}

function handleDirents({ result, currentPath, context }) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding jsdoc to all newly/updated functions?

Copy link
Member Author

@RafaelGSS RafaelGSS Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't added jsdoc to these ones because they are not public, they are used inside readdirRecursive (which has JSDoc). It seems a pattern on this file.

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

lib/fs.js Outdated Show resolved Hide resolved
Copy link
Contributor

@LiviaMedeiros LiviaMedeiros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node/lib/fs.js

Line 1533 in 982a50e

options = getOptions(options);

If options gets mutated (for example, to be reused subsequent readdir) after the function call during the directory processing, the results might become unpredictable. We should copyObject() it.

lib/fs.js Outdated Show resolved Hide resolved
lib/fs.js Outdated Show resolved Hide resolved
lib/fs.js Outdated Show resolved Hide resolved
Copy link
Contributor

@Ethan-Arrowood Ethan-Arrowood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@aduh95
Copy link
Contributor

aduh95 commented Nov 29, 2024

CI is failing

Path: parallel/test-fs-readdir-types-symlinks
Error: --- stderr ---
node:internal/errors:540
      throw error;
      ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Array
    at Object.join (node:path:1261:7)
    at handleFilePaths (node:fs:1458:35)
    at processReaddirResult (node:fs:1437:93)
    at read (node:fs:1497:5)
    at readdirSyncRecursive (node:fs:1505:5)
    at Object.readdirSync (node:fs:1576:12)
    at Object.<anonymous> (/home/runner/work/node/node/test/parallel/test-fs-readdir-types-symlinks.js:34:6)
    at Module._compile (node:internal/modules/cjs/loader:1566:14)
    at Object..js (node:internal/modules/cjs/loader:1718:10)
    at Module.load (node:internal/modules/cjs/loader:1305:32) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Node.js v24.0.0-pre
Command: out/Release/node --test-reporter=spec --test-reporter-destination=stdout --test-reporter=./tools/github_reporter/index.js --test-reporter-destination=stdout /home/runner/work/node/node/test/parallel/test-fs-readdir-types-symlinks.js
=== release test-fs-readdir-recursive ===
Path: sequential/test-fs-readdir-recursive
Error: --- stderr ---
node:internal/errors:540
      throw error;
      ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Array
    at Object.join (node:path:1261:7)
    at handleFilePaths (node:fs:1458:35)
    at processReaddirResult (node:fs:1437:93)
    at read (node:fs:1497:5)
    at readdirSyncRecursive (node:fs:1505:5)
    at Object.readdirSync (node:fs:1576:12)
    at Object.<anonymous> (/home/runner/work/node/node/test/sequential/test-fs-readdir-recursive.js:156:21)
    at Module._compile (node:internal/modules/cjs/loader:1566:14)
    at Object..js (node:internal/modules/cjs/loader:1718:10)
    at Module.load (node:internal/modules/cjs/loader:1305:32) {
  code: 'ERR_INVALID_ARG_TYPE'
}

@RafaelGSS
Copy link
Member Author

Thanks @aduh95. I forgot the readdir tests runs on sequential. I'll check

Copy link
Member

@juanarbol juanarbol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fs.readdir(path, { recursive: true }) is sync
9 participants