Skip to content

fix: skip unreadable files during indexing instead of crashing#253

Open
jimmynail wants to merge 1 commit intotobi:mainfrom
jimmynail:fix/skip-unreadable-files
Open

fix: skip unreadable files during indexing instead of crashing#253
jimmynail wants to merge 1 commit intotobi:mainfrom
jimmynail:fix/skip-unreadable-files

Conversation

@jimmynail
Copy link

Fixes #252

Problem

qmd update crashes when it encounters files that can't be read — specifically iCloud Drive files with the SF_DATALESS flag (evicted content). Node's readFileSync throws EAGAIN (error -11), and since there's no error handling around the read, the entire indexing run dies on the first bad file.

Fix

Wrap the readFileSync call in a try/catch. On failure, skip the file and continue indexing. This is consistent with how qmd already handles empty files (skip and continue).

Impact

Before: a single unreadable file out of 1,540 would crash the entire update.
After: 1,530+ files index successfully, 10 unreadable files are silently skipped.

Testing

Tested against a 1,540-file iCloud Drive shared folder on macOS with 10 evicted files. Before the fix, qmd update crashed at file ~133. After the fix, all 1,540 files are processed (1,530 indexed, 10 skipped).

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

qmd update crashes on iCloud Drive files (EAGAIN / error -11)

1 participant