Uh oh!
There was an error while loading. Please reload this page.
fs,win: fix bug in paths with trailing slashes - #54160
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## main #54160 +/- ##
==========================================
+ Coverage 87.07% 87.10% +0.03%
==========================================
Files 643 647 +4 Lines 181583 181816 +233 Branches 34886 34895 +9 ==========================================
+ Hits 158114 158375 +261 + Misses 16751 16745 -6 + Partials 6718 6696 -22
|
31da37f to
c93a41eComparec93a41e to
733558fCompare| ); | ||
| const validatePath = hideStackFrames((path, propName = 'path') => { | ||
| const validatePath = hideStackFrames((path, propName = 'path', isFile) => { |
There was a problem hiding this comment.
Can you add a JSDoc to this function and adding a small comment that explains the behavior of this new flag?
| constvalidatePath=hideStackFrames((path,propName='path',isFile)=>{ | |
| constvalidatePath=hideStackFrames((path,propName='path',expectFile)=>{ |
| code: 'ERR_FS_EISDIR', | ||
| message: 'is a directory', | ||
| path, | ||
| syscall: 'validatePath', |
There was a problem hiding this comment.
| syscall: 'validatePath', |
There was a problem hiding this comment.
I've applied the fix you suggested, but as you can see the CI doesn't accept throwing an error without a syscall. I didn't get this on Windows, only Linux.
This function is being called from a number of functions that contain different syscalls. Do you have any idea what I can write here?
There was a problem hiding this comment.
I think this syscall should be the name of the fs caller function. Maybe passing it as an argument would be the correct call here? For example, if fs.cpSync() is throwing this error, syscall should be cp. IMHO, Ideally we should throw this error from C++.
There was a problem hiding this comment.
Thanks for the review. Fixed.
Uh oh!
There was an error while loading. Please reload this page.
| * @throws {TypeError} Throws if the path is not a string, Uint8Array, or URL without null bytes. | ||
| * @throws {Error} Throws if the path does not meet the expected type (file). | ||
| */ | ||
| const validatePath = hideStackFrames((path, propName = 'path', expectFile) => { |
There was a problem hiding this comment.
maybe we should go for options instead of expectFile and pass { expectFile: true, syscall: 'cp' }?
There was a problem hiding this comment.
And just check for options != null in 729?
nodejs-github-bot
commented
Aug 11, 2024
anonrig
commented
Aug 11, 2024
cc @nodejs/fs @nodejs/performance |
mcollina
commented
Aug 14, 2024
I have a rough feeling that we might be better to land this as semver-major, or at the bare minimum to not backport to v20 and v18. Wdyt? |
That's my feeling too. I'd not land it on 22 too. Honestly, I'm not confident this design is good/desirable. I can see people forgetting to pass such parameters in a future fs API. |
huseyinacacak-janea
commented
Aug 21, 2024
Is there anything else I can do to help this PR move forward? |
mcollina
commented
Aug 29, 2024
@anonrig@RafaelGSS PTAL |
huseyinacacak-janea
commented
Sep 30, 2024
Can someone take a look at this PR? |
nodejs-github-bot
commented
Oct 10, 2024
Landed in 00b2f07 |
aduh95
commented
Oct 10, 2024
This landed without a recent CI run, resulting in failing linter on |
@huseyinacacak-janea@anonrig This change will cause webpack on windows to fail to save cache files. Remove the following lines of code and recompile node.js to restore to normal. I'm not sure if the problem lies with webpack or here. I wrote an example project that can reproduce this error https://github.com/ShenHongFei/webpack-bug webpack error log |
blexrob
commented
Oct 30, 2024
This also causes trouble for emscripten: emscripten-core/emscripten#22812 |
…6417 Looks like a nodejs bug, introduced in v23.0.0 - commit hash 00b2f07f It should be fixed in v23.2.0 - dd9b6833 bug: nodejs/node#54160fix: nodejs/node#55527 I am able to replicate this on v23.1.0.
This PR fixes the inconsistency across platforms by throwing the same exception on Windows as on Linux.
I've taken the logic and the code in the referenced PR and modified it slightly to allow it to run with the current implementation of Node. Thanks @lundibundi.
Fixes: #17801
Refs: #33831