Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[desktop] macOS folder watch EMFILE workaround

Manav Rathie28ee8ca6674
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