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

fix: catch ELOOP #259

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions glob.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ Glob.prototype._realpathSet = function (index, cb) {
set[real] = true
else if (er.syscall === 'stat')
set[p] = true
else if (er.code === 'ELOOP') {
if (real) set[real] = true
}
else
self.emit('error', er) // srsly wtf right here

Expand Down
3 changes: 3 additions & 0 deletions sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ GlobSync.prototype._finish = function () {
} catch (er) {
if (er.syscall === 'stat')
set[self._makeAbs(p)] = true
else if (er.code === 'ELOOP') {
if (real) set[real] = true
}
else
Copy link
Owner

Choose a reason for hiding this comment

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

What is the intent of this bit? The indentation is incorrect, making it look like any error that isn't a stat or ELOOP will get thrown, but in fact, the only error that'll get thrown is an ELOOP when real is falsey.

Copy link
Owner

Choose a reason for hiding this comment

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

For example:

if (false)
  console.log(1)
else if (false)
  if (true) console.log(2)
else
  console.log(3)

is actually

if (false)
  console.log(1)
else if (false)
  if (true)
    console.log(2)
  else
    console.log(3)

Copy link
Owner

Choose a reason for hiding this comment

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

Also, how can real be set if an error occurred? Does fs.realpath ever return a value if it raises an error? That seems really strange.

Copy link
Author

Choose a reason for hiding this comment

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

added braces to fix the error. I'm going to have to dig back into the code to figure out exactly why we went with setting real... although based on your response at the end of this PR it may not be worth putting in the time.

throw er
}
Expand Down