Skip to content

fs: inconsistent options treatment between rm() and rmdir() #35689

Open
@Trott

Description

@Trott
  • Version: 14.14.0 and 15.0.0-pre (master branch)
  • Platform: macOS
  • Subsystem: fs

What steps will reproduce the bug?

Use /dev/null as the path like below, or use some other path that will not be removed and force a retry.

This tries, doesn't remove /dev/null, and exits with "done" very quickly.

$ node -e 'fs.rmdir("/dev/null", { maxRetries: 42 }, () => { console.log("done"); })'

So does this:

$ node -e 'fs.rmdir("/dev/null", { maxRetries: 420 }, () => { console.log("done"); })'

This does the same:

$ node -e 'fs.rm("/dev/null", { maxRetries: 1 }, () => { console.log("done"); })'

But this takes about 90 seconds to finish, presumably because it is respecting the maxRetries option (with a backoff, I imagine) whereas fs.rmdir() ignores it if recursive is not set:

$ node -e 'fs.rm("/dev/null", { maxRetries: 42 }, () => { console.log("done"); })'

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

Reproduces every time.

What is the expected behavior?

I would expect fs.rm() and fs.rmdir() to treat maxRetries the same.

What do you see instead?

fs.rm() honors it with or without recursive being set, whereas fs.rmdir() ignores it unless recursive is set.

Additional information

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