Skip to content

fs.mkdir/mkdirSync hang with {recursive: true} if name is invalid #28599

Closed
@jeffrson

Description

@jeffrson
  • Version: 10.16.0, 11.14.0, 12.6.0
  • Platform: Windows 10
  • Subsystem: fs

If the name of the dir to be created is invalid, fs.mkdir never calls back and fs.mkdirSync blocks:

const fs = require('fs')

console.log("1")
fs.mkdir('invalid1:', {recursive: true}, (err) => {
  console.log("is not called")
  if (err) throw err
})

console.log("2")
fs.mkdirSync('invalid2:', {recursive: true})
console.log("is not reached")

BTW, the error message that is reported with {recursive: false} appears a bit strange:

Error: ENOENT: no such file or directory, mkdir 'invalid2:'

Wouldn't it be more convenient to use EPERM, EACCES or ENOTDIR?

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.fsIssues and PRs related to the fs subsystem / file system.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions