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 馃樋
const fs = require('fs')
fs.writeFileSync('./test2.txt', '')
fs.mkdirSync('./test2.txt/sub/dir', {
recursive: true
})
See hanging test on travis https://travis-ci.org/sindresorhus/make-dir
Related PR that adds test to make-dir https://github.com/sindresorhus/make-dir/pull/15
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).
This should hang:
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.
@targos if no one else has a moment to dig into this, I can try to tackle it early next week.
Most helpful comment
PR: https://github.com/nodejs/node/pull/27207