-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
mkdir no ERROR when parent is a file with native recursive option #27198
Comments
I tested a bit more on appveyor and now I am not 100% sure if it might be a make-dir issue |
Update, I think it only happens with the callback, mkdirSync I believe is fine (the example above). const fs = require('fs');
fs.writeFileSync('./test2.txt', '');
fs.mkdir('./test2.txt/sub/dir/dir/dir', {
recursive: true
}, function() {
console.log('never calls back')
}); |
Confirmed on my Windows PC: > fs.mkdirSync('package.json/a/b', { recursive: true })
Thrown:
{ Error: EEXIST: file already exists, mkdir 'package.json/a/b'
at Object.mkdirSync (fs.js:773:3)
errno: -4075,
syscall: 'mkdir',
code: 'EEXIST',
path: 'package.json/a/b' }
> fs.mkdir('package.json/a/b', { recursive: true }, console.log)
undefined
> var p = fs.promises.mkdir('package.json/a/b', { recursive: true })
undefined
> p
Promise { <pending> } |
It's actually going into an infinite loop (the process uses 100% of my CPU) |
/cc @nodejs/fs @bcoe |
@targos if no one else has a moment to dig into this, I can try to tackle it early next week. |
If `file` is a file then on Windows `mkdir` on `file/a` returns an `ENOENT` error while on POSIX the equivalent returns `ENOTDIR`. On the POSIX systems `ENOTDIR` would break out of the loop but on Windows the `ENOENT` would strip off the `a` and attempt to make `file` as a directory. This would return `EEXIST` but the code wasn't detecting that the existing path was a file and attempted to make `file/a` again. PR-URL: nodejs#27207 Fixes: nodejs#27198 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ben Coe <bencoe@gmail.com>
Replace try-catch blocks in tests with `assert.rejects()` and `assert.throws()`. PR-URL: nodejs#27207 Fixes: nodejs#27198 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ben Coe <bencoe@gmail.com>
If `file` is a file then on Windows `mkdir` on `file/a` returns an `ENOENT` error while on POSIX the equivalent returns `ENOTDIR`. On the POSIX systems `ENOTDIR` would break out of the loop but on Windows the `ENOENT` would strip off the `a` and attempt to make `file` as a directory. This would return `EEXIST` but the code wasn't detecting that the existing path was a file and attempted to make `file/a` again. PR-URL: #27207 Fixes: #27198 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ben Coe <bencoe@gmail.com>
If `file` is a file then on Windows `mkdir` on `file/a` returns an `ENOENT` error while on POSIX the equivalent returns `ENOTDIR`. On the POSIX systems `ENOTDIR` would break out of the loop but on Windows the `ENOENT` would strip off the `a` and attempt to make `file` as a directory. This would return `EEXIST` but the code wasn't detecting that the existing path was a file and attempted to make `file/a` again. PR-URL: #27207 Fixes: #27198 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ben Coe <bencoe@gmail.com>
On windows Node.js v10.x hangs when trying to mkdir in a path where the parent is a file.
(sorry tested only on appveyor and travis)
Node8 on windows errors with EEXIST
Node10 on non-windows errors ENOTDIR
Node10 on windows hangs NO error 😿
See hanging test on travis https://travis-ci.org/sindresorhus/make-dir
Related PR that adds test to
make-dir
sindresorhus/make-dir#15The text was updated successfully, but these errors were encountered: