Skip to content

Commit 7c5655e

Browse files
author
Myles Borins
committed
fix: catch ELOOP
fs.realpath has been optimized to utilize `uv_fs_realpath()`, a new api in libuv. The libuv api has slightly different behavior. There are two particular issues that are causing problems for glob * `ev_fs_realpath()` throwing before `fs.readdir` ELOOP * The removal of the cache In the past glob was relying on `fs.readdir` to throw when handling recursive symbolically linked directories. It is now possible that the call to libuv can throw before. The behavior is currently different on osx and linux causing the test suite to fail on all of the flavors of linux we are running in CI. This commit adds an extra check for 'ELOOP' and sets appropriately. The commit includes an extra check to make sure that `real` is truthy Without that extra check the test suite was reporting garbage data in the results. This was only happening with the async implementation. This commit has not done anything regarding the removal of the cache As long as the cache doesn't include a value called "encoding" everything will be fine. There has not been any benchmarking done on this change. ref: libuv/libuv#531 ref: nodejs/node#3594
1 parent 68f2509 commit 7c5655e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

glob.js

+3
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ Glob.prototype._realpathSet = function (index, cb) {
237237
set[real] = true
238238
else if (er.syscall === 'stat')
239239
set[p] = true
240+
else if (er.code === 'ELOOP') {
241+
if (real) set[real] = true
242+
}
240243
else
241244
self.emit('error', er) // srsly wtf right here
242245

sync.js

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ GlobSync.prototype._finish = function () {
6262
} catch (er) {
6363
if (er.syscall === 'stat')
6464
set[self._makeAbs(p)] = true
65+
else if (er.code === 'ELOOP') {
66+
if (real) set[real] = true
67+
}
6568
else
6669
throw er
6770
}

0 commit comments

Comments
 (0)