Repository navigation
ENOENT error message inconsistencies #12351
Description
Activity
- addederrorsIssues 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.libuvIssues and PRs related to the libuv dependency or the uv binding.Issues and PRs related to the libuv dependency or the uv binding.processIssues and PRs related to the process subsystem.Issues and PRs related to the process subsystem.
on Apr 12, 2017 - removedlibuvIssues and PRs related to the libuv dependency or the uv binding.Issues and PRs related to the libuv dependency or the uv binding.
on May 17, 2017 I think it is worth unification.
Hi @targos ,
Is this being worked upon? Can I take it?
@aastikta28 I don't think it's being actively worked on. To summary:
- Fixing
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.- Fixing
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.
@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?
@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:
Line 1625 in feaf6ac
return env->ThrowUVException(err, "uv_chdir"); with
env->ThrowUVException(err, "chdir", nullptr, *path, nullptr)should be enough, this would- Display the syscall as
chdirinstead ofuv_chdir - Display the path in the erorr message
You can learn more about how the error message is constructed by reading the code of
UVExceptioninsrc/node.cc.- Display the syscall as
Would like to take a shot at this, if no one else's taking it up.
@SirR4T Heads up: I am currently working on
fs.watchin the last batch of fs errors migrations, but I thinkprocess.chdirhas not been taken.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)Cool, thanks! was about to look into
fs.watchnext. Would like to work on the below instead.Ideally you can even update that to take a context and use
errors.uvExceptionto generate the errors in the JS land but that would be a bigger undertake.Could you elaborate a bit here? or point to your changes in
fsmodule, for reference?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 #19089Hi @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?are there work still pending on this?
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?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)I will close this issue for now, but let us know if you find any more inconsistencies.
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:
I've stumbled upon 2 cases that have different and somehow confusing signatures:
Are these cases worth unification? Can they be addressed in Node.js or they are libuv features?