fs: fix rmSync error messages for non-ASCII paths#61233
Open
Yeaseen wants to merge 1 commit intonodejs:mainfrom
Open
fs: fix rmSync error messages for non-ASCII paths#61233Yeaseen wants to merge 1 commit intonodejs:mainfrom
Yeaseen wants to merge 1 commit intonodejs:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #61233 +/- ##
==========================================
- Coverage 88.54% 88.54% -0.01%
==========================================
Files 704 704
Lines 208738 208736 -2
Branches 40278 40272 -6
==========================================
- Hits 184833 184816 -17
- Misses 15914 15948 +34
+ Partials 7991 7972 -19
🚀 New features to boost your workflow:
|
83b37bd to
a836c7f
Compare
fs.rmSync previously embedded paths directly into custom error messages while also passing the path to ThrowErrnoException. This caused duplicated paths for ASCII names and corrupted paths for non-ASCII directory names on Linux, and inconsistent path formatting on Windows. Remove path concatenation from custom messages and rely on ThrowErrnoException to attach the path safely. Add a test to cover non-ASCII directory names.
a836c7f to
a68d666
Compare
|
8,5/10. Ce document est clair, techniquement précis et facile à comprendre. Sa structure est fluide et explique le problème et sa solution sans détails superflus. Pour atteindre 9 ou 10, il faudrait simplifier légèrement quelques Casino Frumzi phrases ou ajouter une courte phrase de conclusion soulignant l'impact pour les utilisateurs ou les responsables de la maintenance. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes incorrect and inconsistent error messages produced by
fs.rmSyncwhen deletion fails, especially for directories containing non-ASCII characters. The issue affected Linux and Windows differently but shared the same root cause: paths were embedded into custom error messages while also being passed separately toThrowErrnoException.1. Duplicate paths in error messages (Linux, ASCII paths)
fs.rmSyncconstructed messages like:Because
ThrowErrnoExceptionautomatically appends the path, this resulted in duplicated paths when directory names were ASCII-only:2. Corrupted paths for non-ASCII directory names (Linux)
When the directory name contained non-ASCII characters, embedding the path into the message caused UTF-8 bytes to be misinterpreted.
Example:
Here, the first byte of the UTF-8 sequence was interpreted as a Latin-1 character (
é), corrupting the path shown in the error message.3. Inconsistent Windows paths (?\ prefix)
On Windows,
err.pathcould expose raw extended-length paths prefixed with\\?\\, because the platform-specific normalization logic (StringFromPath) was not applied when constructingErrnoException.Example:
This is inconsistent with other fs APIs used in
src/api/exceptions, which strip the prefix before exposing paths to JavaScript.This PR fixes the issue by:
pathargument toThrowErrnoExceptionStringFromPathinsrc/api/exceptionsfor Windows soerr.pathis normalized correctlyA new test has been added:
test-fs-rmSync-special-char-additional-error.jsto verify that:fs.rmSyncreports the correct error codeerr.pathpreserves non-ASCII directory nameserr.messageincludes the correct path@joyeecheung @anonrig Please review this when you are available.