-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
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
base: main
Are you sure you want to change the base?
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 ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #58674 +/- ##
==========================================
- Coverage 90.09% 90.08% -0.01%
==========================================
Files 640 640
Lines 188271 188271
Branches 36923 36916 -7
==========================================
- Hits 169625 169607 -18
- Misses 11386 11405 +19
+ Partials 7260 7259 -1
🚀 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 |
db318e6
to
8c18cc5
Compare
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 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ethan-Arrowood <[email protected]> Reviewed-By: Juan José <[email protected]>
Add PR-URL and Reviewed-By fields to the commit message |
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 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ethan-Arrowood <[email protected]> Reviewed-By: Juan José <[email protected]>
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 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ethan-Arrowood <[email protected]> Reviewed-By: Juan José <[email protected]>
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 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ethan-Arrowood <[email protected]> Reviewed-By: Juan José <[email protected]>
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 |
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