From e28ee8ca6674c0d388bea509c69d2e7995f01957 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Wed, 4 Jun 2025 20:15:19 +0530 Subject: [PATCH] [desktop] macOS folder watch EMFILE workaround --- desktop/src/main/services/watch.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/desktop/src/main/services/watch.ts b/desktop/src/main/services/watch.ts index 6f198c513b..4066a91c89 100644 --- a/desktop/src/main/services/watch.ts +++ b/desktop/src/main/services/watch.ts @@ -28,6 +28,13 @@ export const createWatcher = (mainWindow: BrowserWindow) => { // Ask the watcher to wait for a the file size to stabilize before // telling us about a new file. By default, it waits for 2 seconds. awaitWriteFinish: true, + // On macOS we start getting "EMFILE: too many open files" when watching + // large folders. This is a known regression in Chokidar v4: + // https://github.com/paulmillr/chokidar/issues/1385 + // + // The recommended workaround for now is to enable usePolling. Since it + // comes at a performance cost, we only do it where needed (macOS). + ...(process.platform == "darwin" ? { usePolling: true } : {}), }); watcher