Skip to content

Commit 4a62a75

Browse files
committed
fs: handle UV_ENOTDIR in is_uv_error_except_no_entry
Fixes: #56993 Signed-off-by: Juan José Arboleda <[email protected]>
1 parent 532fff6 commit 4a62a75

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/node_file.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ v8::CFunction fast_internal_module_stat_(
10851085
v8::CFunction::Make(FastInternalModuleStat));
10861086

10871087
constexpr bool is_uv_error_except_no_entry(int result) {
1088-
return result < 0 && result != UV_ENOENT;
1088+
return result < 0 && !(result & (UV_ENOENT | UV_ENOTDIR));
10891089
}
10901090

10911091
static void Stat(const FunctionCallbackInfo<Value>& args) {

test/parallel/test-fs-stat.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,8 @@ fs.lstat(__filename, undefined, common.mustCall());
221221
},
222222
);
223223
}
224+
225+
{
226+
// Test that the throwIfNoEntry option works and returns undefined
227+
assert.ok(!(fs.statSync('./wont_exists', { throwIfNoEntry: false })));
228+
}

0 commit comments

Comments
 (0)