Pewarta Proxy

📋 Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

⚙️ Pengaturan Proxy Target

Skip to content

fs: fix cpSync() abort when dest is a dangling symlink - #67142

Open
yohannesjoya wants to merge 1 commit into
nodejs:mainfrom
yohannesjoya:fs-cpsync-dangling-dest
Open

yohannesjoya wants to merge 1 commit into
nodejs:mainfrom
yohannesjoya:fs-cpsync-dangling-dest

Conversation

@yohannesjoya

Copy link
Copy Markdown

fs.cpSync() aborted the process (exit code 134) when the destination is a dangling symlink. CpSyncCheckPaths() called the throwing overload of std::filesystem::equivalent(), and the uncaught C++ exception bypassed JavaScript's try/catch. It now uses the std::error_code overload, as the parent-directory check further down already does. A dangling destination is not the same file as the source, so the copy goes ahead and replaces the link, matching v24 and fs.promises.cp().

Fixes: #67141

The new test aborts on main and passes with this change. tools/test.py parallel/test-fs-cp-* (91 tests), cpplint and make lint-js pass locally.

Not changed here: copying a symlink onto a dangling symlink with cpSync() still throws a catchable ENOENT from statSync(dest) in onLink(), as on v24. I can follow up on that separately.

AI disclosure: I used a coding agent to help locate the cause and draft the test. I reproduced the crash on v25.9.0, v26.13.0 and main, compared it with v24.22.2, reviewed the change line by line, and ran the tests above locally.

CpSyncCheckPaths() used the throwing overload of
std::filesystem::equivalent(), which fails when dest is a dangling
symlink. The uncaught C++ exception aborted the process. Use the
std::error_code overload instead: a dangling dest is not the same file
as src, so the copy goes ahead and replaces the link.

Fixes: nodejs#67141
Signed-off-by: yohannesjoya <yohannesdestagebru10@gmail.com>
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to file-system APIs and the fs module. needs-ci PRs that need a full CI run. labels Oct 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Node.js, and thank you for your first contribution!

Before review, please take a moment to read:

Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal.

@codecov

codecov Bot commented Oct 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.67%. Comparing base (2500371) to head (11dc3ab).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67142      +/-   ##
==========================================
- Coverage   90.67%   90.67%   -0.01%     
==========================================
  Files         797      797              
  Lines      278806   278774      -32     
  Branches    53621    53609      -12     
==========================================
- Hits       252813   252780      -33     
- Misses      16341    16350       +9     
+ Partials     9652     9644       -8     
Files with missing lines Coverage Δ
src/node_file.cc 76.11% <100.00%> (-0.05%) ⬇️

... and 25 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to file-system APIs and the fs module. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fs.cpSync() aborts the process when the destination is a dangling symlink

3 participants