fix(search): cap child-process stdout to prevent main-process OOM#225
Merged
Conversation
file-search, file-grep, and recent-images buffered unbounded mdfind/rg/grep stdout into a single string and split it on newlines. On machines with huge Spotlight indexes this accumulated hundreds of MB, and the split's cons-string flatten exhausted the V8 heap, crashing the main process (presented as a 120s hang in macOS stackshot reports). Add captureBoundedStdout(), which SIGTERMs the child once 8M chars are buffered and keeps the truncated prefix, and apply it to all five spawn sites. Also cap recent-images' recursive readdir path collection at 1000 entries. Root-cause analysis is documented in docs/learnings/main-process-oom-unbounded-search-stdout.md. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
file-search.ts,file-grep.ts, andrecent-images.tsbuffering unboundedmdfind/rg/grepstdout into one string and splitting it on newlines — on big Spotlight indexes this reaches hundreds of MB and the split's cons-string flatten exhausts the heapcaptureBoundedStdout()(src/main/bounded-stdout.ts): accumulates child stdout and SIGTERMs the process once 8M chars are buffered, keeping the truncated prefix; applied to all five spawn sites (incl. fallbacks)recent-imagesrecursive readdir collection at 1000 paths; adds a learnings doc covering the root cause and how to re-symbolicate stripped Electron stackshots with breakpad symbolsTest plan
npm run typecheckpassesnpx eslintclean on all touched filesvitest run: 977 passed, 0 failed (includes 3 new tests for truncation/kill behavior insrc/main/__tests__/bounded-stdout.test.ts)🤖 Generated with Claude Code