fix(opencode): sort log files before cleanup to avoid deleting newest#16541
fix(opencode): sort log files before cleanup to avoid deleting newest#16541maharshi365 wants to merge 2 commits intoanomalyco:devfrom
Conversation
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate PRs Found:
Recommendation: PR #14792 and #7245 appear to be addressing the exact same bugs you're fixing. You should check their status (open/merged/closed) and verify if they've already been resolved or if there's an opportunity to consolidate efforts. |
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
Fixes #14731
cleanup()inlog.tshad two bugs that caused it to delete the newest log files instead of the oldest:Glob.scanreturns files in non-deterministic filesystem order. Without.sort(),slice(0, -10)could remove the newest files instead of oldest.cleanup()was called withoutawaitininit(), racing with new log file creation — the new file could appear in the glob results and get deleted.<= 5but the keep count was 10, making it inconsistent.Verified: ran
bun test test/util/log.test.ts— 4 pass. Stashed the fix and re-ran — 4 fail (Log.cleanup is not a function/ wrong files deleted).