Repository navigation
Conversation
Mounting a collection containing multi-MB or malformed .bru files could crash the app or drop request detail. Four related changes to the mount parse pipeline: - Redact request bodies >= 512KB before parsing. The grammar parser's memory scales badly with input, so full-parsing large .bru files OOMs the pool's worker threads (~2s and OOM for a 2MB file on a small worker heap). Body blocks are stripped from the raw text before parsing and reinserted after (~1-15ms). Mirrors utils/parse.js, at a lower threshold since the worker heap is much smaller than the watcher's main thread. - Cap each pool worker's heap (resourceLimits.maxOldGenerationSizeMb). A job that still exceeds it is terminated with a recoverable ERR_WORKER_OUT_OF_MEMORY that rejects only that job -- the file is flagged as errored and the mount continues -- instead of a V8 process abort that took the whole app down. - Recover partial meta (name/type/seq) when a full parse fails and keep it in the tree state, so a corrupt request shows its real identity as a partial node instead of collapsing to the bare filename. - Attach the collection-root file pathname to tree.root so collection settings no longer shows an empty path.
WalkthroughChanges affect mount reconciliation error-state persistence, tree root pathname assignment, worker pool thread memory limits, and file-parsing logic that adds redaction for large Bruno request bodies plus structured error handling with partial results on parse failure. ChangesMount, Pool, and Parse Fixes
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/bruno-electron/src/services/mount/manager.js (1)
187-208: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winPersist the partial/error state in the index
entry.statekeeps the parse failure in memory, butthis.#getIndex().entries()only restores{ data }from disk. After a reload, that node comes back as a normal request instead of a partial one. Persist an error/partial marker alongsidedataso corrupted files reopen with the same state.
packages/bruno-electron/src/services/mount/manager.js:191-194🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-electron/src/services/mount/manager.js` around lines 187 - 208, The index update path in the mount manager is only persisting successful parses, while parse failures are kept only in entry.state and lost on reload. Update the transaction in manager.js around the parsed/removed loop to stage and restore an explicit partial/error marker alongside data for failed parses, so `#getIndex`().entries() can reconstruct the same state after reopening. Use the existing entry.state handling and `#getIndex`().stage call as the places to persist and replay this marker for each relativePath.
🧹 Nitpick comments (1)
packages/bruno-electron/src/services/pool/jobs/parse-file.js (1)
8-77: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd unit tests for the new redaction and partial-recovery logic.
parseLargeBruRequest,extractBruMeta, and theparseFiletry/catch fallback are new, isolated, and easily testable pure(ish) functions handling the core bug this PR fixes (large/corrupt.brufiles). No accompanying tests were included. As per coding guidelines, "Add tests for any new functionality or meaningful changes," and "Prioritise high-value tests over maximum coverage... testing behaviour that is critical, complex, or likely to break."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-electron/src/services/pool/jobs/parse-file.js` around lines 8 - 77, Add unit tests covering the new recovery path in parseFile, especially the parseLargeBruRequest redaction flow, extractBruMeta fallback, and the try/catch partial result behavior. Test that large .bru requests route through parseLargeBruRequest and preserve extracted body fields, that corrupt .bru request content falls back to extractBruMeta with partial:true and error details, and that non-request or non-bru parse failures still return the partial shape from parseFile. Use the function names parseLargeBruRequest, extractBruMeta, and parseFile to locate the new logic.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/bruno-electron/src/services/pool/index.js`:
- Around line 16-20: The workerpool created in the pool initializer should
recover when a worker dies from a resourceLimits/OOM exit so the pool does not
permanently shrink. Update the pool setup around the workerpool.pool call to
detect worker exit/failure in the pool management logic and recreate or replace
the dead worker so the pool maintains the configured maxWorkers. Use the
existing pool class and its initialization path to add this resilience without
changing the public API.
---
Outside diff comments:
In `@packages/bruno-electron/src/services/mount/manager.js`:
- Around line 187-208: The index update path in the mount manager is only
persisting successful parses, while parse failures are kept only in entry.state
and lost on reload. Update the transaction in manager.js around the
parsed/removed loop to stage and restore an explicit partial/error marker
alongside data for failed parses, so `#getIndex`().entries() can reconstruct the
same state after reopening. Use the existing entry.state handling and
`#getIndex`().stage call as the places to persist and replay this marker for each
relativePath.
---
Nitpick comments:
In `@packages/bruno-electron/src/services/pool/jobs/parse-file.js`:
- Around line 8-77: Add unit tests covering the new recovery path in parseFile,
especially the parseLargeBruRequest redaction flow, extractBruMeta fallback, and
the try/catch partial result behavior. Test that large .bru requests route
through parseLargeBruRequest and preserve extracted body fields, that corrupt
.bru request content falls back to extractBruMeta with partial:true and error
details, and that non-request or non-bru parse failures still return the partial
shape from parseFile. Use the function names parseLargeBruRequest,
extractBruMeta, and parseFile to locate the new logic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d95421ed-ac81-49cb-af29-8488b4469dd7
📒 Files selected for processing (4)
packages/bruno-electron/src/services/mount/manager.jspackages/bruno-electron/src/services/mount/tree-builder.jspackages/bruno-electron/src/services/pool/index.jspackages/bruno-electron/src/services/pool/jobs/parse-file.js
Problem
Opening a collection with very large or malformed
.brufiles could crash the app (JavaScript heap out of memory) or make corrupted requests show up blank.Fix
metablock) and show it as a partial node, instead of falling back to the bare filename.Summary by CodeRabbit
New Features
Bug Fixes