Repository navigation
ENOENT error message inconsistencies #12351
Copy link
Copy link
Closed
Labels
errorsIssues and PRs related to JavaScript errors originating in Node.js core.Issues and PRs related to JavaScript errors originating in Node.js core.fsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.processIssues and PRs related to the process subsystem.Issues and PRs related to the process subsystem.
Description
- Version: 8.0.0-rc.0
- Platform: Windows 7 x64
- Subsystem: errors, fs, libuv, process
Currently, most of the ENOENT error messages have a similar signature:
Error: ENOENT: no such file or directory, [call] '/full/path/to/filename'
For example:
fs.accessSync('does-not-exist'); // etc...Error: ENOENT: no such file or directory, access '...does-not-exist'
Error: ENOENT: no such file or directory, chmod '...does-not-exist'
Error: ENOENT: no such file or directory, link '...does-not-exist' -> '...does-not-exist2'
Error: ENOENT: no such file or directory, lstat '...does-not-exist'
Error: ENOENT: no such file or directory, open '...does-not-exist'
Error: ENOENT: no such file or directory, readlink '...does-not-exist'
Error: ENOENT: no such file or directory, rename '...does-not-exist' -> '...does-not-exist2'
Error: ENOENT: no such file or directory, rmdir '...does-not-exist'
Error: ENOENT: no such file or directory, scandir '...does-not-exist'
Error: ENOENT: no such file or directory, stat '...does-not-exist'
Error: ENOENT: no such file or directory, unlink '...does-not-exist'
Error: ENOENT: no such file or directory, utime '...does-not-exist'
I've stumbled upon 2 cases that have different and somehow confusing signatures:
- Different order, no description, filename without quotes, no full path:
fs.watch('does-not-exist');
// Error: watch does-not-exist ENOENT- No file name / path at all (the call name can be wrongly considered as the file name):
process.chdir('does-not-exist');
// Error: ENOENT: no such file or directory, uv_chdirAre these cases worth unification? Can they be addressed in Node.js or they are libuv features?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
errorsIssues and PRs related to JavaScript errors originating in Node.js core.Issues and PRs related to JavaScript errors originating in Node.js core.fsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.processIssues and PRs related to the process subsystem.Issues and PRs related to the process subsystem.
Activity
targos commentedon Sep 3, 2017
I think it is worth unification.
aastikta28 commentedon Jan 4, 2018
Hi @targos ,
Is this being worked upon? Can I take it?
joyeecheung commentedon Jan 4, 2018
@aastikta28 I don't think it's being actively worked on. To summary:
process.chdirinvolves updating theThrowUVExceptioncall inChdirinsrc/node.cctoThrowUVException(err, "chdir", nullptr, *path, nullptr). Ideally you can even update that to take a context and useerrors.uvExceptionto generate the errors in the JS land but that would be a bigger undertake.Fixing. (EDIT: it'sfs.watchwould involve updatingnode_stat_watcher.ccto throw an error with the one generated by the C++UVExceptionfunction insrc/node.cc, or better, updating it to take a context and throw the error in JS land using the JS counterparterrors.uvExceptioninstead oferrnoException, this requires a bit more workfs_event_wrap.ccforfs.watch,node_stat_watcher.ccforfs.watchFile, also,node_stat_watcher.ccdoest not even handle errors..)Either way the C++ side of things must be updated, so I am not sure if this is a good first issue, if you are comfortable with C++ and the bindings then it certainly could be. I guess the
process.chdirone should be trivial enough though if you choose to only update the C++ code without migrating that toerrors.uvException. If you want to take it, feel free to ping me in the PR for reviews or mentoring. I am working on migrating the errors in fs but have not reached this part yet, would be happy to get a helping hand. If no one takes it I believe I will eventually get to this part anyway.joyeecheung commentedon Jan 4, 2018
Ah, also just realized this is a breaking change since it changes the error messages that are likely to be matched by the users, I am not sure if there are any popular modules that special-case for these errors. The fixes would need CITGM runs.
aastikta28 commentedon Jan 4, 2018
@joyeecheung Thanks for the wonderful explanation. It looks way more complicated than I thought. But, I can definitely get started on the trivial part of just updating the c++ code for process.chdir without any migration. How can I get started on that?
joyeecheung commentedon Jan 5, 2018
@aastikta28 You can check out the contributing guide on general guidance for building Node, committing and submitting PRs. To fix the error message, replace this:
node/src/node.cc
Line 1625 in feaf6ac
with
env->ThrowUVException(err, "chdir", nullptr, *path, nullptr)should be enough, this wouldchdirinstead ofuv_chdirYou can learn more about how the error message is constructed by reading the code of
UVExceptioninsrc/node.cc.SirR4T commentedon Mar 2, 2018
Would like to take a shot at this, if no one else's taking it up.
joyeecheung commentedon Mar 2, 2018
@SirR4T Heads up: I am currently working on
fs.watchin the last batch of fs errors migrations, but I thinkprocess.chdirhas not been taken.joyeecheung commentedon Mar 2, 2018
BTW, I wrote a file name wrong in #12351 (comment) , to fix
fs.watch,fs_event_wrap.ccneeds to be changed instead ofnode_stat_watcher.ccbecause that one is forfs.watchFile(node_stat_watcher.ccdoes not throw any errors, also...it does not even check the error code returned from libuv! 😱I am going to fix that after #19089 lands to make it more consistent withfs.watch)SirR4T commentedon Mar 2, 2018
Cool, thanks! was about to look into
fs.watchnext. Would like to work on the below instead.Could you elaborate a bit here? or point to your changes in
fsmodule, for reference?joyeecheung commentedon Mar 2, 2018
@SirR4T See #19089
joyeecheung commentedon Mar 2, 2018
Also, forget about the second part of #12351 (comment), it turns out that the particular errors in
fs.watchare actually pretty easy to fix if we don't change the error code (which is what grants a CITGM run really, and the current way it is we are not going to toucherror.codeinfsbefore v10 I believe). Butfs.watchhas a its own can of worms so I added a bunch more stuff in #19089SirR4T commentedon Mar 3, 2018
Hi @joyeecheung , still trying to understand what "take a context" would mean here. In #19089, I see that in C++ land, an
FSEventWrapis unwrapped, processed on, and a return value of error is set, whenever an error occurs. This is then checked for in JS land. Forprocess.chdir(), I couldn't find any JS land wrappers. Where should I be starting here?gireeshpunathil commentedon Apr 27, 2018
are there work still pending on this?
SirR4T commentedon Aug 3, 2018
I can see that
fs.watchandprocess.chdirhave been fixed on master. Not sure if there are other inconsistencies, though. How would one go about checking that?vsemozhetbyt commentedon Aug 3, 2018
I cannot think of another way than just iterating over all appropriate
fsmethods. But there may not be any more issues if those were fixed)vsemozhetbyt commentedon Aug 3, 2018
I will close this issue for now, but let us know if you find any more inconsistencies.