-
Notifications
You must be signed in to change notification settings - Fork 30k
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
deprecate fs.exists post io.js 1.0.0 #257
Comments
Related: original PR to deprecate fs.exists #103 |
Related discussion on joyent/node: fs.exists is not being deprecated in 0.12 nodejs/node-v0.x-archive#8418 |
One counterargument to your 'this deprecation is super noisy as fs.exists is used everywhere' argument is that it's used incorrectly almost everywhere. :-) I don't have a strong opinion on whether to keep or revert the deprecation notice - seeing how people are often using fs.exists wrong, it's better when it's gone; on the other hand, incompatibilities between io.js and node.js aren't nice - but deprecation notices can be turned off if updating your code is not an option. |
@bnoordhuis swapping |
So my understanding on the " permissions
race conditionsThe race-conditions issue is outlined in the node documentation:
i.e. Between an Without any mechanism for multiple atomic filesystem operations, this issue isn't at all constrained to In summary: Is any of this incorrect or misguided? |
@timoxley That's correct. fs.access() is a limited but faster fs.stat() (and can be abused for adding strace-visible logging, but that aside.) |
There're basically two reasons:
no opinion about 1.0.0 vs post-1.0.0 deprecation here |
perhaps we need an intermediate type of deprecation for these deprecations that cause incompatibilities with joyent/node that's a bit gentler—perhaps just limiting to a stderr print once during execution rather than every time it's accessed:
|
Didn't we have this discussion already here: #103 ? |
@rvagg That's how it works. The output from the OP looks like a number of child processes all calling fs.exists() and fs.existsSync(). |
ah, ok then, well I guess my suggestion here is to handle these things just like we do in the browser.. first person to publish an |
@trevnorris @chrisdickinson or @indutny - any chance of just landing nodejs/node-v0.x-archive#8714 to keep things in sync? |
AFAICT In every other server side oriented language there is an equivalent for Weird choice if you ask me, I also wonder how many real-world scenarios had problems becuase of such race condition ( probably docummented in some other linked discussion ) |
|
Personally I don't see how How do I know write pretty common use-case i.e. if (!fs.existsSync('compiled.data')) {
// compile and save data
} with |
That's the kind of incorrect use I was talking about earlier. What happens when two processes check for compiled.data at the same time? There is no single good answer because it's a race condition. |
I admit the
It's also worth reiterating that |
It's important, but not for everyone, so it doesn't make sense to make check more difficult for those who don't need it. When I write developer tools (CLI), I don't really care about several processes as user himself is single-threaded :)
This makes sense, but throwing error where all that you want is yes/no boolean, doesn't feel intuitive as well. Even if this extended code would be at least a return value for |
+1 let's not show the deprecation warning for fs.exists yet. |
Closed in 3a85eac |
FWIW |
The discussion on the original node issue and this one assumes that the only reason to check if a file exists is to do something with that file. (The Node.js documentation further assumes that what you want to do is open it.) Sometimes all you want to know is that the file exists. Why can't there be a function that does nothing other than tell you this? I get the race conditions, but it's making things complicated for the sake of saving developers from themselves. |
@matthew-dean There's no kernel API that allows this to happen. The simplest check you can use to accomplish the same thing is to use |
tl;dr Unless the PR to get
fs.access
merged into joyent/node gets merged before io.js 1.0.0 hits, I have a feeling this deprecation may cost more than it's worth.Anyone following the recommendation to use
fs.access
instead is instantly making their code incompatible with node, and for little gain.In addition, this deprecation is super noisy as
fs.exists
is (mis)used everywhere.Yes, you can turn the deprecation notices off, but it's not ideal.
What is the upgrade path for a module author whose code would otherwise 'just work' without annoying deprecation notices on both node 0.10, 0.12 and io.js?
Wondering if this deprecation (and any other changes like it) should be introduced after a 1.0.0 release. I'm all for rocking the boat but perhaps it would serve the io.js interests better if there isn't too much turbulence at first.
The text was updated successfully, but these errors were encountered: