-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
Open
Description
Version
v19.0.0-pre
Platform
any
Subsystem
lib
What steps will reproduce the bug?
import fs from 'node:fs/promises';
const DIR = '/tmp/issue43401';
const defaultDirOptions = { recursive: true };
async function run(dirOptions) {
await fs.rm(DIR, { recursive: true, force: true });
console.log('dirOptions.recursive:', dirOptions.recursive);
try {
await fs.mkdir(`${DIR}/1/2/3/4`, dirOptions);
await fs.rm(DIR, dirOptions);
await fs.stat(DIR);
} catch(e) {
console.error(e);
}
}
await run({});
await run({ recursive: true });
await run(Object.create(defaultDirOptions));
run()
tries to create nested directories, then remove them, then access topmost one.
- When ran with
{}
,mkdir
must fail withENOENT
because it's not recursive. - When ran with
{ recursive: true }
,stat
must fail withENOENT
because directory was deleted.
Depending on if we care that each property is "own", Object.create(defaultDirOptions)
should behave either as (1) or as (2).
However, currently rm
fails with EISDIR
. So, mkdir
is recursive but rm
is not.
How often does it reproduce? Is there a required condition?
It depends on methods, it depends on version (pretty sure that some of these are changed within semver-patch
level).
For some methods is might even depend on which property we access or on something even less related.
What is the expected behavior?
Consistency.
Or a warning somewhere, that only ownProperties are guaranteed to work.
Or an explicit agreement that it's UB "by design".
What do you see instead?
Inconsistency.
Additional information
In most cases, inherited properties are dropped by copying (e.g. { ...options }
).
Metadata
Metadata
Assignees
Labels
No labels