-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
fs: fix TypeError in glob when directory access is denied #58674
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
Conversation
This is nice! Thanks! Would you mind adding a test case? Just make sure that it will never return null |
@juanarbol Done. Added test case |
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! Thanks!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #58674 +/- ##
==========================================
+ Coverage 89.97% 89.99% +0.02%
==========================================
Files 649 649
Lines 192194 192194
Branches 37678 37683 +5
==========================================
+ Hits 172918 172958 +40
+ Misses 11873 11836 -37
+ Partials 7403 7400 -3
🚀 New features to boost your workflow:
|
6b33002
to
7ae4597
Compare
Delete the test-fs-glob-readdir-error-handling.mjs file as its functionality is now covered by the test-fs-glob.mjs |
8c18cc5
to
0a4f0f9
Compare
Add PR-URL and Reviewed-By fields to the commit message |
f1789b7
to
a5fdb0f
Compare
I think you need to stop force-pushing so it can land. Another contributor can correct me if I'm wrong though |
Sorry for the force-push. Could you please help re-approve this PR so it can land? Thank you |
Failed to start CI⚠ Commits were pushed since the last approving review: ⚠ - fs: fix glob TypeError on restricted dirs ⚠ - Merge branch 'nodejs:main' into main ✘ Refusing to run CI on potentially unsafe PRhttps://github.com/nodejs/node/actions/runs/16320742288 |
It seems like the CI did not run because new commits were pushed after the last approving review? |
The last CI failures ultimately point to node-test-commit-arm-debug node-test-binary-windows-js-suites The first one had network issues when cloning the git repository, the second one had ECONNRESET error during inspector testing. This might be coincidental since there have never been problems before. PR #59091 explains the why Windows CI failure in this PR. |
Another CI node-test-commit-aix failure: |
@Sylphy-0xd3ac It seems your first commit doesn't have the correct author. Can you squash all your 10 commits and make sure to |
When a directory cannot be read due to permission issues, the async version of fs.glob() returns null from readdir(), while the sync version returns an empty array. This causes a TypeError when trying to access the 'length' property of null. PR-URL: #58674 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ethan-Arrowood <ethan@arrowood.dev> Reviewed-By: Juan José <soyjuanarbol@gmail.com>
@RafaelGSS I did it, is that it? |
Yes! Once CI is green (again), PR will be merged. |
When a directory cannot be read due to permission issues, the async version of fs.glob() returns null from readdir(), while the sync version returns an empty array. This causes a TypeError when trying to access the 'length' property of null. PR-URL: #58674 Fixes: #58670 Fixes: #58276 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ethan-Arrowood <ethan@arrowood.dev> Reviewed-By: Juan José <soyjuanarbol@gmail.com>
Landed in 5794e64 |
When a directory cannot be read due to permission issues, the async version of fs.glob() returns null from readdir(), while the sync version returns an empty array. This causes a TypeError when trying to access the 'length' property of null. PR-URL: nodejs#58674 Fixes: nodejs#58670 Fixes: nodejs#58276 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ethan-Arrowood <ethan@arrowood.dev> Reviewed-By: Juan José <soyjuanarbol@gmail.com>
When a directory cannot be read due to permission issues, the async version of fs.glob() returns null from readdir(), while the sync version returns an empty array. This causes a TypeError when trying to access the 'length' property of null.
Fix by making the async readdir() method return an empty array on error, consistent with the sync version behavior.
Fixes: #58670
Fixes: #58276