-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: stop search if files names are undefined #6761
Conversation
a432e4b
to
d56dcf3
Compare
Codecov Report
@@ Coverage Diff @@
## master #6761 +/- ##
==========================================
- Coverage 66.98% 66.98% -0.01%
==========================================
Files 250 250
Lines 10360 10363 +3
Branches 3 3
==========================================
+ Hits 6940 6942 +2
- Misses 3419 3420 +1
Partials 1 1
Continue to review full report at Codecov.
|
@@ -30,7 +30,10 @@ function find( | |||
activeCalls++; | |||
fs.readdir(directory, (err, names) => { | |||
activeCalls--; | |||
|
|||
if (!names) { |
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.
How about going a bit more idiomatic Node.js with if (err) {
?
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.
Yeah, if that's what happens (unhandled error) that's the correct fix. @emuraton do you have a reproduction case for your error?
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.
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.
If it returns undefined names, but null err, it's a bug in Node imho and you should also file it there
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.
Agreed, the docs says you should always get an array: https://nodejs.org/api/fs.html#fs_fs_readdir_path_options_callback
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.
Sorry for the late answer, after double thought I think you were right before actually. Checking err
should be enough.
If I find a bit of time today, I'll try to replicate to see if its a bug from Node or if your first comments were right
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.
Thanks, looking forward to it!
After few tests cases, I always got something following this shape. So I think checking
|
a1796df
to
0f79b06
Compare
Could you update the changelog as well? :) |
CHANGELOG.md
Outdated
@@ -9,6 +9,7 @@ | |||
- `[babel-jest]` Make `getCacheKey()` take into account `createTransformer` options ([#6699](https://github.com/facebook/jest/pull/6699)) | |||
- `[docs]` Fix contributors link ([#6711](https://github.com/facebook/jest/pull/6711)) | |||
- `[website]` Fix website versions page to link to correct language ([#6734](https://github.com/facebook/jest/pull/6734)) | |||
- `[jest-haste-map`] Catch crawler error when unsuccessfully reading directories ([#6761](https://github.com/facebook/jest/pull/6761)) |
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.
You'll need to rebase/merge master, as this CHANGELOG is outdated (latest Jest release is 23.5.0)
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.
nvm, fixed that for you :)
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.
Thanks 👍
This reverts commit d235839.
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Files names seems to be undefined on certain cases for Window
I'm not sure why this variable is undefined, but I added defensive code to return earlier more gracefuly.
Test plan
Added an unit test to confirm we return early if
names
is undefined.fixes: #6715