Skip to content

fs: preserve filename when recursive watch root file is removed - #65882

Open
cuishuang wants to merge 1 commit into
nodejs:mainfrom
cuishuang:main
Open

fs: preserve filename when recursive watch root file is removed#65882
cuishuang wants to merge 1 commit into
nodejs:mainfrom
cuishuang:main

Conversation

@cuishuang

Copy link
Copy Markdown

When the JavaScript recursive watcher is used, removing a watched root file emits an empty filename.

This happens because the deletion path uses the root-relative filename, and the relative path of the root file to itself is empty. The same watcher emits the basename for change events, while native recursive watchers also report the basename.

Emit the basename in the root-file deletion branch to keep the result consistent with change events and native recursive watchers.

Tests:

  • Add a regression test for fsPromises.watch() on a root file.
  • Update the existing Linux recursive watcher expectation.

Refs: #65486

Signed-off-by: cuishuang <imcusg@gmail.com>
@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to file-system APIs and the fs module. needs-ci PRs that need a full CI run. labels Sep 7, 2026
@github-actions

github-actions Bot commented Sep 7, 2026

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.

Caution

AgentScan found account activity patterns that may be consistent with automation. This is a heuristic, not proof that this pull request was opened by an agent or violates policy. AI-assisted contributions are permitted, but automated tooling must not open pull requests without advance approval, and contributors must personally understand, test, verify, and take responsibility for every submitted change. See the AgentScan analysis, AI use policy, and automation policy for additional context.

@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.18%. Comparing base (9f7ae86) to head (f2f3382).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65882      +/-   ##
==========================================
- Coverage   90.19%   90.18%   -0.01%     
==========================================
  Files         771      771              
  Lines      264911   265094     +183     
  Branches    50323    50351      +28     
==========================================
+ Hits       238939   239082     +143     
- Misses      16922    16963      +41     
+ Partials     9050     9049       -1     
Files with missing lines Coverage Δ
lib/internal/fs/recursive_watch.js 85.12% <100.00%> (ø)

... and 38 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

agentscan:automated-account 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.

2 participants