-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #56041 +/- ##
========================================
Coverage 88.00% 88.01%
========================================
Files 653 656 +3
Lines 188093 189077 +984
Branches 35942 36006 +64
========================================
+ Hits 165537 166412 +875
- Misses 15734 15840 +106
- Partials 6822 6825 +3
|
} | ||
} | ||
|
||
function handleDirents({ result, currentPath, context }) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
CI is failing
|
Thanks @aduh95. I forgot the readdir tests runs on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sgtm
for (let i = 0; i < context.pathsQueue.length; i++) { | ||
read(context.pathsQueue[i]); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is somewhat out of scope of the PR, I just wondered if we want to limit the amount of reads triggered to an upper bound of available file descriptors? That way we would not allocate anything before it's needed and it would probably reduce memory and increase performance a tad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that makes sense. But I wouldn't include it on this PR as it just fixes an async behavior. Currently, fs.readdir() - async
performs one operation per time:
-> readdir -> cb -> readdir -> cb ...
But at some point, we could read from parallel folders within the same callback, which would improve performance significantly (memory would increase, though).
Commit Queue failed- Loading data for nodejs/node/pull/56041 ✔ Done loading data for nodejs/node/pull/56041 ----------------------------------- PR info ------------------------------------ Title lib: fix fs.readdir recursive async (#56041) Author Rafael Gonzaga <[email protected]> (@RafaelGSS) Branch RafaelGSS:fix-readdir-async-throw -> nodejs:main Labels fs, author ready Commits 3 - lib: fix fs.readdir recursive async - fixup! lib: fix fs.readdir recursive async - fixup! fixup! lib: fix fs.readdir recursive async Committers 1 - RafaelGSS <[email protected]> PR-URL: https://github.com/nodejs/node/pull/56041 Fixes: https://github.com/nodejs/node/issues/56006 Reviewed-By: Ethan Arrowood <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/56041 Fixes: https://github.com/nodejs/node/issues/56006 Reviewed-By: Ethan Arrowood <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> -------------------------------------------------------------------------------- ⚠ Commits were pushed since the last approving review: ⚠ - fixup! fixup! lib: fix fs.readdir recursive async ℹ This PR was created on Wed, 27 Nov 2024 20:05:17 GMT ✔ Approvals: 2 ✔ - Ethan Arrowood (@Ethan-Arrowood): https://github.com/nodejs/node/pull/56041#pullrequestreview-2470295506 ✔ - Juan José Arboleda (@juanarbol): https://github.com/nodejs/node/pull/56041#pullrequestreview-2470693898 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2024-12-04T20:46:30Z: https://ci.nodejs.org/job/node-test-pull-request/63877/ - Querying data for job/node-test-pull-request/63877/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/12172531267 |
Could someone re-approve? I pushed 16a29cb after approvals. |
Landed in 53356c3 |
Fixes: #56006 PR-URL: #56041 Reviewed-By: Ethan Arrowood <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]>
Fixes: #56006 PR-URL: #56041 Reviewed-By: Ethan Arrowood <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]>
Fixes: #56006 PR-URL: #56041 Reviewed-By: Ethan Arrowood <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]>
Fixes: #56006 PR-URL: #56041 Reviewed-By: Ethan Arrowood <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]>
Fixes: #56006 PR-URL: #56041 Reviewed-By: Ethan Arrowood <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]>
Fixes: #56006 PR-URL: #56041 Reviewed-By: Ethan Arrowood <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]>
* chore: bump node in DEPS to v22.13.1 * chore: fixup GN build file * nodejs/node#55529 * nodejs/node#55798 * nodejs/node#55530 * module: simplify --inspect-brk handling nodejs/node#55679 * src: fix outdated js2c.cc references nodejs/node#56133 * crypto: include openssl/rand.h explicitly nodejs/node#55425 * build: use variable for crypto dep path nodejs/node#55928 * crypto: fix RSA_PKCS1_PADDING error message nodejs/node#55629 * build: use variable for simdutf path nodejs/node#56196 * test,crypto: make crypto tests work with BoringSSL nodejs/node#55491 * fix: suppress clang -Wdeprecated-declarations in libuv libuv/libuv#4486 * deps: update libuv to 1.49.1 nodejs/node#55114 * test: make test-node-output-v8-warning more flexible nodejs/node#55401 * [v22.x] Revert "v8: enable maglev on supported architectures" nodejs/node#54384 * fix: potential WIN32_LEAN_AND_MEAN redefinition c-ares/c-ares#869 * deps: update nghttp2 to 1.64.0 nodejs/node#55559 * src: provide workaround for container-overflow nodejs/node#55591 * build: use variable for simdutf path nodejs/node#56196 * chore: fixup patch indices * fixup! module: simplify --inspect-brk handling * lib: fix fs.readdir recursive async nodejs/node#56041 * lib: avoid excluding symlinks in recursive fs.readdir with filetypes nodejs/node#55714 This doesn't currently play well with ASAR - this should be fixed in a follow up * test: disable CJS permission test for config.main This has diverged as a result of our revert of src,lb: reducing C++ calls of esm legacy main resolve * fixup! lib: fix fs.readdir recursive async * deps: update libuv to 1.49.1 nodejs/node#55114 --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <[email protected]>
Fixes: #56006
cc: @aduh95 @Ethan-Arrowood