ENOENT error in gulp.src when glob pattern does not match any files
0 reputation · 03 Jun 2023, 17:07 UTC
When developing a gulp build, the goal is to reliably detect missing source files through the ENOENT error emitted by gulp.src, while also ensuring that file‑watching tasks do not accumulate listeners that cause a memory leak.
The current gulp 4 documentation describes the ENOENT behavior for non‑existent glob patterns but does not specify whether gulp.watch should automatically close its internal chokidar watchers after a task finishes or expose an option like ignoreInitial to reduce listener churn. This leaves developers to decide whether to reuse a single watcher or to access internal APIs for cleanup, which may break in future releases.
What is the recommended approach for handling the ENOENT error in gulp.src when a glob pattern yields no matches? Should gulp.watch provide automatic watcher cleanup or an ignore‑initial flag to prevent listener accumulation? Are there any version‑specific behaviors in chokidar that affect the need for manual cleanup?