-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fs: remove experimental language from rmdir recursive #35171
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Promise-based rmdir()
should be updated as well.
doc/api/fs.md
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be OK to drop the reference to rimraf
and just explain this function's behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
|
@nodejs/fs |
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 |
Refs: #34278 PR-URL: #35171 Reviewed-By: Christopher Hiller <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
This was missed in commit 35b17d9. Refs: nodejs#34278 Refs: nodejs#35171 Signed-off-by: Anders Kaseorg <[email protected]>
This missed the |
This was missed in commit 35b17d9. Refs: #34278 Refs: #35171 Signed-off-by: Anders Kaseorg <[email protected]> PR-URL: #36131 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ben Coe <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
This was missed in commit 35b17d9. Refs: #34278 Refs: #35171 Signed-off-by: Anders Kaseorg <[email protected]> PR-URL: #36131 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ben Coe <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
This was missed in commit 35b17d9. Refs: #34278 Refs: #35171 Signed-off-by: Anders Kaseorg <[email protected]> PR-URL: #36131 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ben Coe <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
This was missed in commit 35b17d9. Refs: #34278 Refs: #35171 Signed-off-by: Anders Kaseorg <[email protected]> PR-URL: #36131 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ben Coe <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
This was missed in commit 35b17d9. Refs: #34278 Refs: #35171 Signed-off-by: Anders Kaseorg <[email protected]> PR-URL: #36131 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ben Coe <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
Refs: nodejs#34278 PR-URL: nodejs#35171 Reviewed-By: Christopher Hiller <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
Notable changes: * fs: * remove experimental from rmdir recursive (Benjamin Coe) [nodejs#35171](nodejs#35171) PR-URL: nodejs#35525
I would like to make a case for removing the experimental flag from
rmdir
'srecursive
option:recursive
option, due to it being experimental.Regarding #34278, "Rethink
recursive
flag".As a compromise, I initially looked at raising an
ENOENT
exception, if the initialpath
provided tormdir
did 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
recursive
behavior in ourtmpdir.js
helper ... It also drilled home for me that deviating fromrimraf
might not be a great idea...An alternative compromise
What if we explicitly call out in documentation the fact that setting
recursive
totrue
gives 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-extra
avoids setting therecursive
option. But, as our own use case intmdir.js
demonstrates, therecursive
option, 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