From 1264c9ca5dfb9dd3a4b88fbbc813ea54fe4e0f83 Mon Sep 17 00:00:00 2001 From: Abdullah Alaqeel Date: Wed, 29 Jul 2026 23:37:45 +0300 Subject: [PATCH] fix(fs-watcher): validate roots before watch() for Node 24/26 compat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Node 24/26 on Linux changed fs.watch() to defer errors for nonexistent paths to the async 'error' event instead of throwing synchronously. The existing start() relied on the synchronous throw to populate failures and leave watchers empty, so on Node 24/26 Linux the 'could not watch any of the configured roots' guard never fired — watch() returned a handle that got pushed regardless, making watchers.length non-zero. statSync(root) + isDirectory() check at the top of the existing try block catches nonexistent/non-directory roots synchronously on every platform and Node version, so the guard fires deterministically. Signed-off-by: Abdullah Alaqeel --- integrations/filesystem-watcher/watcher.mjs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integrations/filesystem-watcher/watcher.mjs b/integrations/filesystem-watcher/watcher.mjs index d68b2b8d16..c7c68a084f 100644 --- a/integrations/filesystem-watcher/watcher.mjs +++ b/integrations/filesystem-watcher/watcher.mjs @@ -248,6 +248,8 @@ export class FilesystemWatcher { const failures = []; for (const root of this.roots) { try { + const st = statSync(root); + if (!st.isDirectory()) throw new Error("not a directory"); const handle = watch( root, { recursive: true, persistent: true },