diff --git a/src/node_file.cc b/src/node_file.cc index c35f8aa839ef75..0547b2d35debf3 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -1278,6 +1278,7 @@ int MKDirpSync(uv_loop_t* loop, } break; case UV_EACCES: + case UV_ENOTDIR: case UV_EPERM: { return err; } @@ -1356,6 +1357,7 @@ int MKDirpAsync(uv_loop_t* loop, break; } case UV_EACCES: + case UV_ENOTDIR: case UV_EPERM: { req_wrap->continuation_data()->Done(err); break; @@ -1398,7 +1400,6 @@ int MKDirpAsync(uv_loop_t* loop, } // verify that the path pointed to is actually a directory. if (err == 0 && !S_ISDIR(req->statbuf.st_mode)) err = UV_EEXIST; - uv_fs_req_cleanup(req); req_wrap->continuation_data()->Done(err); }}); if (err < 0) req_wrap->continuation_data()->Done(err); diff --git a/test/parallel/test-fs-mkdir.js b/test/parallel/test-fs-mkdir.js index e0e20f942cefae..add0926f8379f6 100644 --- a/test/parallel/test-fs-mkdir.js +++ b/test/parallel/test-fs-mkdir.js @@ -148,6 +148,7 @@ function nextdir() { message: /ENOTDIR: .*mkdir/, name: 'Error', syscall: 'mkdir', + path: pathname // See: https://github.com/nodejs/node/issues/28015 } ); } @@ -187,6 +188,11 @@ function nextdir() { assert.strictEqual(err.code, 'ENOTDIR'); assert.strictEqual(err.syscall, 'mkdir'); assert.strictEqual(fs.existsSync(pathname), false); + // See: https://github.com/nodejs/node/issues/28015 + // The path field varies slightly in Windows errors, vs., other platforms + // see: https://github.com/libuv/libuv/issues/2661, for this reason we + // use startsWith() rather than comparing to the full "pathname". + assert(err.path.startsWith(filename)); })); }