Repository navigation
fix(stats): bound retained events during stalled writes - #20941
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to No merge-blocking issue was identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description explains the problem, solution, and validation, but it omits most required template sections, including ELI5, Linked Issue, Visual Proof with an N/A explanation, Testing checkboxes, Review, boundary confirmation, Notes, and Checklist items. Resolution Complete the required template sections. Add an ELI5 summary, a linked issue after “Fixes #”, Visual Proof with “N/A” and a reason because this is not a UI change, testing details and checkbox status, review information, the agent skill upstream boundary checkbox, notes on compatibility and performance, and the applicable checklist confirmations. ✨ Finishing Touches📝 Generate docstrings
Warning Git: CodeRabbit could not clone the repository, so clone-backed analysis was skipped and this review may be incomplete. Verify repository clone access, such as SSH credentials, before requesting another full review. If clone access is intentionally unavailable, use 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.
✅ No new issues found.
Reviewed changes
- In-memory retention during stalled writes —
record()insrc/main/stats/collector.tsnow trimsthis.eventstoMAX_EVENTSimmediately after each push, closing the window where a write parked onwriteFiledeferred the cap untilserialize()ran. - Regression test —
bounds retained events while a stalled write prevents serializationholds the async write open, records a seed plus 20,000 events, asserts the in-memory bound mid-stall, and then asserts the persisted newest-10k order plus lifetime aggregates.
The new cap is redundant with the serialize() trim only for the normal path; keeping both is correct since serialize() still guards events loaded from an oversized on-disk file. updateAggregates is called on the incoming event after trimming, so lifetime totals are preserved. I confirmed the regression test is real by reverting just the record() cap: it fails with expected 10001 to be less than or equal to 10000, and pnpm test src/main/stats passes 24/24 with the fix.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
* fix(stats): cap retained events before asynchronous persistence * test: use typed access in memory retention regressions --------- Co-authored-by: m4air <[email protected]> Co-authored-by: m4air <[email protected]>

Stats events were capped only when a snapshot was serialized. A stalled asynchronous profile write could delay serialization indefinitely while new events kept accumulating in Electron main.
Apply the existing 10,000-event limit when each event is recorded. Keep the newest events and preserve lifetime aggregate totals.
Validation: 24 stats tests passed, including a regression that blocks a write, records more than 20,000 events, checks the in-memory bound before serialization, and verifies the saved order and lifetime totals after unblocking. Targeted oxlint and oxfmt passed.