Skip to content

Conversation

@mcollina
Copy link
Member

Add an ignore option to fs.watch() to filter filesystem events.

Type: string | RegExp | Function | Array<string | RegExp | Function>

fs.watch(dir, { ignore: '*.log' });
fs.watch(dir, { ignore: /\.tmp$/ });
fs.watch(dir, { ignore: (f) => f.startsWith('.') });
fs.watch(dir, { ignore: ['*.log', /\.tmp$/] });

Add an `ignore` option to `fs.watch()` to filter filesystem events.
Supports string globs, RegExp, functions, or arrays of these.
@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Jan 18, 2026
@mcollina mcollina marked this pull request as ready for review January 18, 2026 23:29
@mcollina mcollina requested review from aduh95 and anonrig and removed request for anonrig January 18, 2026 23:30
mohmedsa22242-cell

This comment was marked as spam.

@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.53%. Comparing base (637bda0) to head (cbcd51e).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61433      +/-   ##
==========================================
+ Coverage   88.51%   88.53%   +0.02%     
==========================================
  Files         704      704              
  Lines      208883   209004     +121     
  Branches    40334    40371      +37     
==========================================
+ Hits       184890   185049     +159     
+ Misses      15977    15928      -49     
- Partials     8016     8027      +11     
Files with missing lines Coverage Δ
lib/fs.js 98.19% <100.00%> (+<0.01%) ⬆️
lib/internal/fs/recursive_watch.js 85.01% <100.00%> (+0.65%) ⬆️
lib/internal/fs/watchers.js 87.37% <100.00%> (+2.20%) ⬆️
lib/internal/validators.js 98.25% <100.00%> (+0.09%) ⬆️

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

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 19, 2026
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 19, 2026
@nodejs-github-bot
Copy link
Collaborator

Use setInterval instead of setTimeout to handle potential event delays
on macOS FSEvents. This ensures that if a write event is missed due to
event coalescing or latency, subsequent writes will eventually trigger
the expected event.
@avivkeller avivkeller added semver-minor PRs that contain new features and should be released in the next minor version. notable-change PRs with changes that should be highlighted in changelogs. labels Jan 19, 2026
@github-actions
Copy link
Contributor

The notable-change PRs with changes that should be highlighted in changelogs. label has been added by @avivkeller.

Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section.

Comment on lines +81 to +85
let minimatch;
function lazyMinimatch() {
minimatch ??= require('internal/deps/minimatch/index');
return minimatch;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a lazy utility in internal utils

@aduh95
Copy link
Contributor

aduh95 commented Jan 19, 2026

It looks like there's a consistent failure on macOS

AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

true !== false

    at process.<anonymous> (/Users/runner/work/node/node/node/test/parallel/test-fs-watch-ignore-recursive.js:165:12)
    at process.emit (node:events:520:22) {
  generatedMessage: true,
  code: 'ERR_ASSERTION',
  actual: true,
  expected: false,
  operator: 'strictEqual',
  diff: 'simple'
}

Node.js v26.0.0-pre
Command: out/Release/node /Users/runner/work/node/node/node/test/parallel/test-fs-watch-ignore-recursive.js

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

Labels

fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants