| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
The Promise-based rmdir() should be updated as well.
Sorry, something went wrong.
There was a problem hiding this comment.
I think it would be OK to drop the reference to rimraf and just explain this function's behavior.
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
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.
Sorry, something went wrong.
There was a problem hiding this comment.
@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?
Sorry, something went wrong.
There was a problem hiding this comment.
That sounds good to me 👍
Sorry, something went wrong.
|
Playing a bit with GitHub's search, it's also clear that quite a few folks have been using the recursive option. This perhaps speaks to the fact that we should have had a warning when the recursive setting was added? It feels like, going forward, we should do this for experimental options? |
Sorry, something went wrong.
I believe that is already the policy, it was just missed here. |
Sorry, something went wrong.
|
+1 to going stable with it. Maybe the ENOENT behavior can be made available with an option? (Not in this PR, though.) |
Sorry, something went wrong.
@Trott I really like this idea, perhaps we introduce an option like recursiveStrict and work with the fs-extra to make the behavior closer to what folks would expect building a library on top of it. |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
lgtm
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
@boneskull to be clear, are you flatly opposed to changing the way that recursive works by default in any way, including fixing the fact that it deletes both files and directories? |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
There are two different groups of people 😛
I am an advocate for an additional flag (perhaps recursiveStrict?). We could work with you to make sure is closer to the expectations from a POSIX perspective. I am also -1 on deprecating the existing feature. Wearing the hat of someone writing small command line tools, behavior like rm -rf is frequently what I want.
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:
|
Sorry, something went wrong.
|
@nodejs/fs |
Sorry, something went wrong.
As of Node v14.10.1, fs.rmdir(file, {recursive: true}) still deletes the file with no error. This should be fixed before this is considered stable. As far as the ENOENT stuff goes, it's still a bit odd, but if it's clearly documented (which it currently is), I'm not going to make a big fight about it. In a perfect world, recursive would be its own method, but unfortunately, it looks like we're past that point. |
Sorry, something went wrong.
My concern about changing this behavior is just that it moves us away from the behavior of rm -rf, and makes the feature slightly harder to describe/puts a bit more burden on the user. I'm personally -0 on this change; but would be supportive of a consensus in either direction. One thought, it might be good to look at some of the other platforms that have added rmdir recursive:
I'd be interested to see what decision these other platforms have taken, when given a file path rather than directory. |
Sorry, something went wrong.
It does move away from rm -rf, but this is recursive rmdir, not rm. I don't see how this really makes it harder to describe, it's doing exactly what it says, recursively removing a directory, with a note that it won't throw if the path doesn't exist. |
Sorry, something went wrong.
|
@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). |
Sorry, something went wrong.
|
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 rmdir -r as it is (To @bcoe's point) except that it will throw when deleting a file only (To @RyanZim's point) and maybe on a missing path (I wouldn't bother too much either way due to what comes next). Lets then have another function rm (or you might want to call it something else) with a strict implementation matching (at least similar to) POSIX rm that gives users more fine-grained control. |
Sorry, something went wrong.
This was missed in commit 35b17d9. Refs: nodejs#34278 Refs: nodejs#35171 Signed-off-by: Anders Kaseorg <andersk@mit.edu>
|
This missed the Stability: 1 line under fsPromises.rmdir. Fix submitted as #36131. |
Sorry, something went wrong.
This was missed in commit 35b17d9. Refs: #34278 Refs: #35171 Signed-off-by: Anders Kaseorg <andersk@mit.edu> PR-URL: #36131 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This was missed in commit 35b17d9. Refs: #34278 Refs: #35171 Signed-off-by: Anders Kaseorg <andersk@mit.edu> PR-URL: #36131 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This was missed in commit 35b17d9. Refs: #34278 Refs: #35171 Signed-off-by: Anders Kaseorg <andersk@mit.edu> PR-URL: #36131 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This was missed in commit 35b17d9. Refs: #34278 Refs: #35171 Signed-off-by: Anders Kaseorg <andersk@mit.edu> PR-URL: #36131 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This was missed in commit 35b17d9. Refs: #34278 Refs: #35171 Signed-off-by: Anders Kaseorg <andersk@mit.edu> PR-URL: #36131 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Refs: nodejs#34278 PR-URL: nodejs#35171 Reviewed-By: Christopher Hiller <boneskull@boneskull.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Notable changes: * fs: * remove experimental from rmdir recursive (Benjamin Coe) [nodejs#35171](nodejs#35171) PR-URL: nodejs#35525
| Back | FazBrowse Home | New Git URL |
I would like to make a case for removing the experimental flag from rmdir's recursive option:
Regarding #34278, "Rethink recursive flag".
As a compromise, I initially looked at raising an ENOENT exception, if the initial path provided to rmdir did not exist ... I was thinking perhaps we could get away with deviating a bit from rimraf's behavior, in the name of reaching consensus.
This immediately broke our test test suite, because we rely on the current recursive behavior in our tmpdir.js helper ... It also drilled home for me that deviating from rimraf might not be a great idea...
An alternative compromise
What if we explicitly call out in documentation the fact that setting recursive to true gives you behavior that matches the community module rimraf?
It might be the case that, due to some of the oddities in this API surface, a module like fs-extra avoids setting the recursive option. But, as our own use case in tmdir.js demonstrates, the recursive option, as it exists today, is great for a variety of tooling needs.
CC: @CxRes, @nodejs/tooling, @RyanZim, @iansu
Refs: #34278
Checklist