fix: skip unreadable files during indexing instead of crashing#253
Open
fix: skip unreadable files during indexing instead of crashing#253
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #252
Problem
qmd updatecrashes when it encounters files that can't be read — specifically iCloud Drive files with theSF_DATALESSflag (evicted content). Node'sreadFileSyncthrowsEAGAIN(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
readFileSynccall 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 updatecrashed at file ~133. After the fix, all 1,540 files are processed (1,530 indexed, 10 skipped).