Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upfs: remove experimental language from rmdir recursive #35171
Conversation
|
The Promise-based |
| @@ -3532,6 +3530,10 @@ to the completion callback. | |||
| Using `fs.rmdir()` on a file (not a directory) results in an `ENOENT` error on | |||
| Windows and an `ENOTDIR` error on POSIX. | |||
|
|
|||
| Setting `recursive` to `true` results in behavior similar to the rimraf package | |||
cjihrig
Sep 13, 2020
Contributor
I think it would be OK to drop the reference to rimraf and just explain this function's behavior.
I think it would be OK to drop the reference to rimraf and just explain this function's behavior.
cjihrig
Sep 13, 2020
Contributor
My personal point of view: I don't think I've ever directly used the rimraf module in my own code, so referencing it here would force me to go read about implied behavior of an npm module in order to understand how core works. That feels a little backward.
I don't feel strongly about it though. If you think it's important to note, then it's fine with me.
My personal point of view: I don't think I've ever directly used the rimraf module in my own code, so referencing it here would force me to go read about implied behavior of an npm module in order to understand how core works. That feels a little backward.
I don't feel strongly about it though. If you think it's important to note, then it's fine with me.
bcoe
Sep 13, 2020
Author
Member
@cjihrig I looked at the rimraf docs, they point out that rimraf has behavior similar to rm -rf. Why don't we use this language instead of calling out the module name?
@cjihrig I looked at the rimraf docs, they point out that rimraf has behavior similar to rm -rf. Why don't we use this language instead of calling out the module name?
cjihrig
Sep 13, 2020
Contributor
That sounds good to me 👍
That sounds good to me
|
Playing a bit with GitHub's search, it's also clear that quite a few folks have been using the This perhaps speaks to the fact that we should have had a |
I believe that is already the policy, it was just missed here. |
|
+1 to going stable with it. Maybe the ENOENT behavior can be made available with an option? (Not in this PR, though.) |
@Trott I really like this idea, perhaps we introduce an option like |
|
lgtm |
|
Although I can sympathize with the intent of this PR, it seems like a band-aid to cover up what is already an oversight of design. The problem of going ahead with just the language change is that deeper issues that have been raised, will in all likelihood remain unaddressed, which I think is the worst possible outcome. At least, I would urge the community to make a good faith attempt to find solutions from which we might find the compromise. I, for example, would not mind the introduction of new flags as a compromise, as suggested above (though my preference would be to deprecate the recursive flag but not removing it for the foreseeable future). Also, I agree that the documentation should refer to rm -rf and not rimraf. @bcoe It seems you are trying to argue your case both ways:
and
I point this out, not to criticize, but to bring to attention to the deeper questions on how new features are to be onboarded in Node! These are more social issues such as what should be honored - documentation or popularity. Should we change experimental feature to achieve a more consistent API or will it be the case that experimental features will not be changed once they become reasonably popular (or when warnings have not been added)? This question is above my pay grade (though I hold strong opinions); what is certain is that either answer will lead to considerable developer pain. |
|
|
LGTM |
@boneskull to be clear, are you flatly opposed to changing the way that |
|
It should not remove a file if given a file (unsure if that's still a bug). But it should remove all files within a directory if given a directory. |
There are two different groups of people
I am an advocate for an additional flag (perhaps I am also
I care deeply about listening to people and finding great compromises whenever possible. I apologize that this wasn't how I came across in my initial reaction to #34278. I think what's difficult here is that we have two significantly different perspectives:
|
As of Node v14.10.1, As far as the |
My concern about changing this behavior is just that it moves us away from the behavior of I'm personally One thought, it might be good to look at some of the other platforms that have added
I'd be interested to see what decision these other platforms have taken, when given a file |
It does move away from |
|
@RyanZim having done a bit of a review of other languages, I've honestly come around to either wanting us to stick with the very liberal implementation (how things sit today). Or moving wholesale to a stricter implementation where both non directory paths and missing paths throw. I couldn't find a precedent that throws on a non-directory, but allows a missing path (in the languages I looked at). |
|
Let me propose a part of my original solution as alternative that might satisfy both the groups of users and cause minimum disruption (but at the cost of some redundancy): Lets leave |
Changes to experimental features aren't semver-major, so I guess it depends how we go about this.... |
|
@Trott @BridgeAR @mcollina @mhdawson, etc., please take a look based on conversation today:
@iansu has offered to update their work, to add the new |
| Setting `recursive` to `true` results in behavior similar to the Unix command | ||
| `rm -rf`: an error will not be raised for paths that do not exist, and paths | ||
| that represent files will be deleted. The permissive behavior of the | ||
| `recursive` option is deprecated, `ENOTDIR` and `ENOENT` will be thrown in |
bcoe
Oct 1, 2020
Author
Member
@nodejs/tsc I thought it might be most elegant in v16 that we make rmdir/recursive either match the behavior of .NET, Python, or Deno, with folks using rm if the want looser (rather than introducing yet another method). Which is how I landed on this language...
I figure we have some time to get this perfect, with it being most important for Node@v15 that we:
- try to land a new method
rm.
- get the deprecation in place for folks using the existing approach.
@nodejs/tsc I thought it might be most elegant in v16 that we make rmdir/recursive either match the behavior of .NET, Python, or Deno, with folks using rm if the want looser (rather than introducing yet another method). Which is how I landed on this language...
I figure we have some time to get this perfect, with it being most important for Node@v15 that we:
- try to land a new method
rm. - get the deprecation in place for folks using the existing approach.
|
LGTM |
|
I plan on landing this tomorrow hopefully, please let me know if anyone has additional feedback. |
|
LGTM (and I like the idea of adding an option to enable the |
|
Landed in 35b17d9 |
I would like to make a case for removing the experimental flag from
rmdir'srecursiveoption:recursiveoption, due to it being experimental.Regarding #34278, "Rethink
recursiveflag".As a compromise, I initially looked at raising an
ENOENTexception, if the initialpathprovided tormdirdid not exist ... I was thinking perhaps we could get away with deviating a bit fromrimraf's behavior, in the name of reaching consensus.This immediately broke our test test suite, because we rely on the current
recursivebehavior in ourtmpdir.jshelper ... It also drilled home for me that deviating fromrimrafmight not be a great idea...An alternative compromise
What if we explicitly call out in documentation the fact that setting
recursivetotruegives you behavior that matches the community modulerimraf?It might be the case that, due to some of the oddities in this API surface, a module like
fs-extraavoids setting therecursiveoption. But, as our own use case intmdir.jsdemonstrates, therecursiveoption, as it exists today, is great for a variety of tooling needs.CC: @CxRes, @nodejs/tooling, @RyanZim, @iansu
Refs: #34278
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes