Commit 7f75746
committed
fs: fix cpSync directory iterator exception
This patch prevents process abort when fs.cpSync() encounters errors
while iterating directories with non-ASCII characters in paths.
Previously, std::filesystem::directory_iterator was constructed without
an error_code parameter, causing it to throw std::filesystem::filesystem_error
on failure. When the underlying libc++ implementation (especially in Electron)
has bugs handling GBK-encoded paths on Windows, this uncaught exception
triggers __libcpp_verbose_abort(), causing the process to crash.
The crash cannot be caught by JavaScript try-catch blocks since it occurs
at the C++ layer below the Node.js binding.
This fix changes the directory_iterator construction to use the error_code
overload, consistent with other std::filesystem operations in this file.
If an error occurs, it is properly converted to a JavaScript exception
via env->ThrowStdErrException(), allowing user code to handle it gracefully.1 parent bf452bb commit 7f75746
1 file changed
+7
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3738 | 3738 | | |
3739 | 3739 | | |
3740 | 3740 | | |
3741 | | - | |
| 3741 | + | |
| 3742 | + | |
| 3743 | + | |
| 3744 | + | |
| 3745 | + | |
| 3746 | + | |
| 3747 | + | |
3742 | 3748 | | |
3743 | 3749 | | |
3744 | 3750 | | |
| |||
0 commit comments