Skip to content

fs.mkdir is inconsistent in the number of arguments passed to the callback , when completed. #43015

@ryan65

Description

@ryan65

Version

16.14

Platform

Window/Linux

Subsystem

No response

What steps will reproduce the bug?

//call mkdir with to create a non existing directory and then when complete call it again with the same directory.
fs.mkdir('c:\\temp\\testdirnonexist',{ recursive: true }, function(){
       console.log('first time', arguments.length); //result 2
       fs.mkdir('c:\\temp\\testdirnonexist',{ recursive: true }, function(){
          console.log('second time', arguments.length); //result 1
       });
});

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

Always return the same number of arguments.
This is important for example when you pass an async waterfall callback to mkdir.

What do you see instead?

if the directory exists only 1 arguments will be returned (error argument which is null)
if directory is created then it returns null, and the path.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions