diff --git a/src/node_file.cc b/src/node_file.cc index 8d43b0ef662796..ddba9ad42ccbc4 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -1234,6 +1234,7 @@ int MKDirpSync(uv_loop_t* loop, } break; case UV_EACCES: + case UV_ENOTDIR: case UV_EPERM: { return err; } @@ -1309,6 +1310,7 @@ int MKDirpAsync(uv_loop_t* loop, break; } case UV_EACCES: + case UV_ENOTDIR: case UV_EPERM: { req_wrap->continuation_data()->Done(err); break; @@ -1351,7 +1353,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 8bec37c1898578..c911587753a091 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)); })); }