fs: add ignore option to fs.watch by mcollina · Pull Request #61433 · nodejs/node
Add an `ignore` option to `fs.watch()` to filter filesystem events. Supports string globs, RegExp, functions, or arrays of these.
added
fs
labels
mcollina
marked this pull request as ready for review
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
added
semver-minor
labels
On macOS, FSEvents reports events for both directories and files. The pattern '**/node_modules/**' only matches files inside node_modules, not the directory itself. Use an array pattern to match both.
Instead of just filtering events, skip watching ignored paths entirely to avoid kernel resource pressure from unnecessary file watchers. This is especially important for large directories like node_modules.
lpinca added a commit to lpinca/node that referenced this pull request
Split and simplify the tests into individual files. Refs: nodejs#61433
aduh95 pushed a commit that referenced this pull request
Add an `ignore` option to `fs.watch()` to filter filesystem events. Supports string globs, RegExp, functions, or arrays of these. PR-URL: #61433 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
islandryu pushed a commit to islandryu/node that referenced this pull request
Add an `ignore` option to `fs.watch()` to filter filesystem events. Supports string globs, RegExp, functions, or arrays of these. PR-URL: nodejs#61433 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
nodejs-github-bot added a commit that referenced this pull request
Notable changes: crypto: * update root certificates to NSS 3.119 (Node.js GitHub Bot) #61419 deps: * (SEMVER-MINOR) add LIEF as a dependency (Joyee Cheung) #61167 * (SEMVER-MINOR) add tools and scripts to pull LIEF as a dependency (Joyee Cheung) #61167 fs: * (SEMVER-MINOR) add ignore option to fs.watch (Matteo Collina) #61433 sea: * (SEMVER-MINOR) add --build-sea to generate SEA directly with Node.js binary (Joyee Cheung) #61167 * (SEMVER-MINOR) split sea binary manipulation code (Joyee Cheung) #61167 sqlite: * (SEMVER-MINOR) enable defensive mode by default (Bart Louwers) #61266 * (SEMVER-MINOR) add sqlite prepare options args (Guilherme Araújo) #61311 src: * use node- prefix on thread names (Stewart X Addison) #61307 test: * (SEMVER-MINOR) migrate to --build-sea in existing SEA tests (Joyee Cheung) #61167 * (SEMVER-MINOR) use fixture directories for sea tests (Joyee Cheung) #61167 test_runner: * (SEMVER-MINOR) support expecting a test-case to fail (Jacob Smith) #60669 PR-URL: #61519
aduh95 added a commit that referenced this pull request
Notable changes: crypto: * update root certificates to NSS 3.119 (Node.js GitHub Bot) #61419 deps: * (SEMVER-MINOR) add LIEF as a dependency (Joyee Cheung) #61167 * (SEMVER-MINOR) add tools and scripts to pull LIEF as a dependency (Joyee Cheung) #61167 fs: * (SEMVER-MINOR) add ignore option to fs.watch (Matteo Collina) #61433 sea: * (SEMVER-MINOR) add `--build-sea` to generate SEA directly with Node.js binary (Joyee Cheung) #61167 * (SEMVER-MINOR) split sea binary manipulation code (Joyee Cheung) #61167 sqlite: * (SEMVER-MINOR) enable defensive mode by default (Bart Louwers) #61266 * (SEMVER-MINOR) add sqlite prepare options args (Guilherme Araújo) #61311 src: * use node- prefix on thread names (Stewart X Addison) #61307 test: * (SEMVER-MINOR) migrate to `--build-sea` in existing SEA tests (Joyee Cheung) #61167 * (SEMVER-MINOR) use fixture directories for sea tests (Joyee Cheung) #61167 test_runner: * (SEMVER-MINOR) support expecting a test-case to fail (Jacob Smith) #60669 PR-URL: #61519
aduh95 added a commit that referenced this pull request
Notable changes: crypto: * update root certificates to NSS 3.119 (Node.js GitHub Bot) #61419 deps: * (SEMVER-MINOR) add LIEF as a dependency (Joyee Cheung) #61167 * (SEMVER-MINOR) add tools and scripts to pull LIEF as a dependency (Joyee Cheung) #61167 fs: * (SEMVER-MINOR) add ignore option to fs.watch (Matteo Collina) #61433 sea: * (SEMVER-MINOR) add `--build-sea` to generate SEA directly with Node.js binary (Joyee Cheung) #61167 * (SEMVER-MINOR) split sea binary manipulation code (Joyee Cheung) #61167 sqlite: * (SEMVER-MINOR) enable defensive mode by default (Bart Louwers) #61266 * (SEMVER-MINOR) add sqlite prepare options args (Guilherme Araújo) #61311 src: * use node- prefix on thread names (Stewart X Addison) #61307 test: * (SEMVER-MINOR) migrate to `--build-sea` in existing SEA tests (Joyee Cheung) #61167 * (SEMVER-MINOR) use fixture directories for sea tests (Joyee Cheung) #61167 test_runner: * (SEMVER-MINOR) support expecting a test-case to fail (Jacob Smith) #60669 PR-URL: #61519
aduh95 added a commit that referenced this pull request
Notable changes: crypto: * update root certificates to NSS 3.119 (Node.js GitHub Bot) #61419 deps: * (SEMVER-MINOR) add LIEF as a dependency (Joyee Cheung) #61167 * (SEMVER-MINOR) add tools and scripts to pull LIEF as a dependency (Joyee Cheung) #61167 fs: * (SEMVER-MINOR) add ignore option to fs.watch (Matteo Collina) #61433 sea: * (SEMVER-MINOR) add `--build-sea` to generate SEA directly with Node.js binary (Joyee Cheung) #61167 * (SEMVER-MINOR) split sea binary manipulation code (Joyee Cheung) #61167 sqlite: * (SEMVER-MINOR) enable defensive mode by default (Bart Louwers) #61266 * (SEMVER-MINOR) add sqlite prepare options args (Guilherme Araújo) #61311 src: * use node- prefix on thread names (Stewart X Addison) #61307 test: * (SEMVER-MINOR) migrate to `--build-sea` in existing SEA tests (Joyee Cheung) #61167 * (SEMVER-MINOR) use fixture directories for sea tests (Joyee Cheung) #61167 test_runner: * (SEMVER-MINOR) support expecting a test-case to fail (Jacob Smith) #60669 PR-URL: #61519
mcollina
deleted the
fs-watch-ignore-option
branch
nodejs-github-bot pushed a commit that referenced this pull request
aduh95 pushed a commit that referenced this pull request
aduh95 pushed a commit that referenced this pull request
aduh95 pushed a commit that referenced this pull request
aduh95 pushed a commit that referenced this pull request
Add an `ignore` option to `fs.watch()` to filter filesystem events. Supports string globs, RegExp, functions, or arrays of these. PR-URL: #61433 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
aduh95 pushed a commit that referenced this pull request
aduh95 pushed a commit that referenced this pull request
nodejs-github-bot added a commit that referenced this pull request
Notable changes: async_hooks: * (SEMVER-MINOR) add trackPromises option to createHook() (Joyee Cheung) #61415 build,deps: * replace cjs-module-lexer with merve (Yagiz Nizipli) #61456 deps: * (SEMVER-MINOR) add LIEF as a dependency (Joyee Cheung) #61167 * (SEMVER-MINOR) add tools and scripts to pull LIEF as a dependency (Joyee Cheung) #61167 events: * (SEMVER-MINOR) repurpose `events.listenerCount()` to accept EventTargets (René) #60214 fs: * (SEMVER-MINOR) add ignore option to fs.watch (Matteo Collina) #61433 http: * (SEMVER-MINOR) add http.setGlobalProxyFromEnv() (Joyee Cheung) #60953 module: * (SEMVER-MINOR) allow subpath imports that start with `#/` (Jan Martin) #60864 process: * (SEMVER-MINOR) preserve AsyncLocalStorage in queueMicrotask only when needed (Gürgün Dayıoğlu) #60913 sea: * (SEMVER-MINOR) split sea binary manipulation code (Joyee Cheung) #61167 sqlite: * (SEMVER-MINOR) enable defensive mode by default (Bart Louwers) #61266 * (SEMVER-MINOR) add sqlite prepare options args (Guilherme Araújo) #61311 src: * (SEMVER-MINOR) add initial support for ESM in embedder API (Joyee Cheung) #61548 stream: * (SEMVER-MINOR) add bytes() method to stream/consumers (wantaek) #60426 * (SEMVER-MINOR) do not pass `readable.compose()` output via `Readable.from()` (René) #60907 test: * (SEMVER-MINOR) use fixture directories for sea tests (Joyee Cheung) #61167 test_runner: * (SEMVER-MINOR) add env option to run function (Ethan Arrowood) #61367 * (SEMVER-MINOR) support expecting a test-case to fail (Jacob Smith) #60669 util: * (SEMVER-MINOR) add convertProcessSignalToExitCode utility (Erick Wendel) #60963 PR-URL: #61924
aduh95 pushed a commit that referenced this pull request
Add an `ignore` option to `fs.watch()` to filter filesystem events. Supports string globs, RegExp, functions, or arrays of these. PR-URL: #61433 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
aduh95 pushed a commit that referenced this pull request
aduh95 added a commit that referenced this pull request
Notable changes: async_hooks: * (SEMVER-MINOR) add `trackPromises` option to `createHook()` (Joyee Cheung) #61415 build,deps: * replace cjs-module-lexer with merve (Yagiz Nizipli) #61456 deps: * (SEMVER-MINOR) add LIEF as a dependency (Joyee Cheung) #61167 events: * (SEMVER-MINOR) repurpose `events.listenerCount()` to accept `EventTarget`s (René) #60214 fs: * (SEMVER-MINOR) add `ignore` option to `fs.watch` (Matteo Collina) #61433 http: * (SEMVER-MINOR) add `http.setGlobalProxyFromEnv()` (Joyee Cheung) #60953 module: * (SEMVER-MINOR) allow subpath imports that start with `#/` (Jan Martin) #60864 process: * (SEMVER-MINOR) preserve `AsyncLocalStorage` in `queueMicrotask` only when needed (Gürgün Dayıoğlu) #60913 sea: * (SEMVER-MINOR) split sea binary manipulation code (Joyee Cheung) #61167 sqlite: * (SEMVER-MINOR) enable defensive mode by default (Bart Louwers) #61266 * (SEMVER-MINOR) add sqlite prepare options args (Guilherme Araújo) #61311 src: * (SEMVER-MINOR) add initial support for ESM in embedder API (Joyee Cheung) #61548 stream: * (SEMVER-MINOR) add `bytes()` method to `node:stream/consumers` (wantaek) #60426 * (SEMVER-MINOR) do not pass `readable.compose()` output via `Readable.from()` (René) #60907 test: * (SEMVER-MINOR) use fixture directories for sea tests (Joyee Cheung) #61167 test_runner: * (SEMVER-MINOR) add `env` option to `run` function (Ethan Arrowood) #61367 * (SEMVER-MINOR) support expecting a test-case to fail (Jacob Smith) #60669 util: * (SEMVER-MINOR) add `convertProcessSignalToExitCode` utility (Erick Wendel) #60963 PR-URL: #61924
aduh95 added a commit that referenced this pull request
Notable changes: async_hooks: * (SEMVER-MINOR) add `trackPromises` option to `createHook()` (Joyee Cheung) #61415 build,deps: * replace cjs-module-lexer with merve (Yagiz Nizipli) #61456 deps: * (SEMVER-MINOR) add LIEF as a dependency (Joyee Cheung) #61167 events: * (SEMVER-MINOR) repurpose `events.listenerCount()` to accept `EventTarget`s (René) #60214 fs: * (SEMVER-MINOR) add `ignore` option to `fs.watch` (Matteo Collina) #61433 http: * (SEMVER-MINOR) add `http.setGlobalProxyFromEnv()` (Joyee Cheung) #60953 module: * (SEMVER-MINOR) allow subpath imports that start with `#/` (Jan Martin) #60864 process: * (SEMVER-MINOR) preserve `AsyncLocalStorage` in `queueMicrotask` only when needed (Gürgün Dayıoğlu) #60913 sea: * (SEMVER-MINOR) split sea binary manipulation code (Joyee Cheung) #61167 sqlite: * (SEMVER-MINOR) enable defensive mode by default (Bart Louwers) #61266 * (SEMVER-MINOR) add sqlite prepare options args (Guilherme Araújo) #61311 src: * (SEMVER-MINOR) add initial support for ESM in embedder API (Joyee Cheung) #61548 stream: * (SEMVER-MINOR) add `bytes()` method to `node:stream/consumers` (wantaek) #60426 * (SEMVER-MINOR) do not pass `readable.compose()` output via `Readable.from()` (René) #60907 test: * (SEMVER-MINOR) use fixture directories for sea tests (Joyee Cheung) #61167 test_runner: * (SEMVER-MINOR) add `env` option to `run` function (Ethan Arrowood) #61367 * (SEMVER-MINOR) support expecting a test-case to fail (Jacob Smith) #60669 util: * (SEMVER-MINOR) add `convertProcessSignalToExitCode` utility (Erick Wendel) #60963 PR-URL: #61924
aduh95 added a commit to aduh95/node that referenced this pull request
Notable changes: async_hooks: * (SEMVER-MINOR) add `trackPromises` option to `createHook()` (Joyee Cheung) nodejs#61415 build,deps: * replace cjs-module-lexer with merve (Yagiz Nizipli) nodejs#61456 deps: * (SEMVER-MINOR) add LIEF as a dependency (Joyee Cheung) nodejs#61167 events: * (SEMVER-MINOR) repurpose `events.listenerCount()` to accept `EventTarget`s (René) nodejs#60214 fs: * (SEMVER-MINOR) add `ignore` option to `fs.watch` (Matteo Collina) nodejs#61433 http: * (SEMVER-MINOR) add `http.setGlobalProxyFromEnv()` (Joyee Cheung) nodejs#60953 module: * (SEMVER-MINOR) allow subpath imports that start with `#/` (Jan Martin) nodejs#60864 process: * (SEMVER-MINOR) preserve `AsyncLocalStorage` in `queueMicrotask` only when needed (Gürgün Dayıoğlu) nodejs#60913 sea: * (SEMVER-MINOR) split sea binary manipulation code (Joyee Cheung) nodejs#61167 sqlite: * (SEMVER-MINOR) enable defensive mode by default (Bart Louwers) nodejs#61266 * (SEMVER-MINOR) add sqlite prepare options args (Guilherme Araújo) nodejs#61311 src: * (SEMVER-MINOR) add initial support for ESM in embedder API (Joyee Cheung) nodejs#61548 stream: * (SEMVER-MINOR) add `bytes()` method to `node:stream/consumers` (wantaek) nodejs#60426 * (SEMVER-MINOR) do not pass `readable.compose()` output via `Readable.from()` (René) nodejs#60907 test: * (SEMVER-MINOR) use fixture directories for sea tests (Joyee Cheung) nodejs#61167 test_runner: * (SEMVER-MINOR) add `env` option to `run` function (Ethan Arrowood) nodejs#61367 * (SEMVER-MINOR) support expecting a test-case to fail (Jacob Smith) nodejs#60669 util: * (SEMVER-MINOR) add `convertProcessSignalToExitCode` utility (Erick Wendel) nodejs#60963 PR-URL: nodejs#61924
ruyadorno pushed a commit that referenced this pull request
Notable changes: async_hooks: * (SEMVER-MINOR) add `trackPromises` option to `createHook()` (Joyee Cheung) #61415 build,deps: * replace cjs-module-lexer with merve (Yagiz Nizipli) #61456 deps: * (SEMVER-MINOR) add LIEF as a dependency (Joyee Cheung) #61167 events: * (SEMVER-MINOR) repurpose `events.listenerCount()` to accept `EventTarget`s (René) #60214 fs: * (SEMVER-MINOR) add `ignore` option to `fs.watch` (Matteo Collina) #61433 http: * (SEMVER-MINOR) add `http.setGlobalProxyFromEnv()` (Joyee Cheung) #60953 module: * (SEMVER-MINOR) allow subpath imports that start with `#/` (Jan Martin) #60864 process: * (SEMVER-MINOR) preserve `AsyncLocalStorage` in `queueMicrotask` only when needed (Gürgün Dayıoğlu) #60913 sea: * (SEMVER-MINOR) split sea binary manipulation code (Joyee Cheung) #61167 sqlite: * (SEMVER-MINOR) enable defensive mode by default (Bart Louwers) #61266 * (SEMVER-MINOR) add sqlite prepare options args (Guilherme Araújo) #61311 src: * (SEMVER-MINOR) add initial support for ESM in embedder API (Joyee Cheung) #61548 stream: * (SEMVER-MINOR) add `bytes()` method to `node:stream/consumers` (wantaek) #60426 * (SEMVER-MINOR) do not pass `readable.compose()` output via `Readable.from()` (René) #60907 test: * (SEMVER-MINOR) use fixture directories for sea tests (Joyee Cheung) #61167 test_runner: * (SEMVER-MINOR) add `env` option to `run` function (Ethan Arrowood) #61367 * (SEMVER-MINOR) support expecting a test-case to fail (Jacob Smith) #60669 util: * (SEMVER-MINOR) add `convertProcessSignalToExitCode` utility (Erick Wendel) #60963 PR-URL: #61924