From 32cd83b4704d4cdce06c43e2d5b01f6bd743816f Mon Sep 17 00:00:00 2001 From: Kit Date: Mon, 23 Feb 2026 14:40:09 -0800 Subject: [PATCH] fix: skip unreadable files during indexing instead of crashing On macOS with iCloud Drive (especially shared folders), some files may appear in the filesystem but return EAGAIN (error -11) when read via Node's readFileSync. This happens when iCloud has evicted the file content but the file metadata remains visible. Previously this crashed the entire update process. Now we catch the error and skip the file, allowing the remaining files to index successfully. Affects: iCloud Drive shared folders on macOS Error: 'Unknown system error -11: Unknown system error -11, read' Reproduces with: Node.js v25.x, readFileSync on evicted iCloud files --- src/qmd.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/qmd.ts b/src/qmd.ts index 090b5c1..eb0489e 100755 --- a/src/qmd.ts +++ b/src/qmd.ts @@ -1455,7 +1455,15 @@ async function indexFiles(pwd?: string, globPattern: string = DEFAULT_GLOB, coll const path = handelize(relativeFile); // Normalize path for token-friendliness seenPaths.add(path); - const content = readFileSync(filepath, "utf-8"); + let content: string; + try { + content = readFileSync(filepath, "utf-8"); + } catch (err: any) { + // Skip files that can't be read (e.g. iCloud evicted files returning EAGAIN) + processed++; + progress.set((processed / total) * 100); + continue; + } // Skip empty files - nothing useful to index if (!content.trim()) {