fix(cron): move session reaper to finally block so it runs reliably#31996
Conversation
There was a problem hiding this comment.
💡 Codex Review
openclaw/src/cron/service/timer.ts
Line 658 in 00c10d5
Placing resolveSessionStorePath calls inside the outer finally means an exception there can abort the same finally block before state.running = false and armTimer(state) run. In that scenario (for example, a throwing resolver implementation), the cron service remains stuck in running state and later ticks only hit the early-return branch, so scheduled jobs stop executing. Before this change, resolver/reaper failures happened in the try block and cleanup still ran in finally.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Greptile SummaryMoves the cron session reaper into the Key changes:
Confidence Score: 5/5
Last reviewed commit: 00c10d5 |
00c10d5 to
fbe2150
Compare
The cron session reaper was placed inside the try block of onTimer(), after job execution and state updates. If the locked persist section threw, the reaper was skipped — causing isolated cron run sessions to accumulate indefinitely in sessions.json. Move the reaper into the finally block so it always executes after a timer tick, regardless of whether job execution succeeded. The reaper is already self-throttled (MIN_SWEEP_INTERVAL_MS = 5 min) so calling it more reliably has no performance impact. Closes openclaw#31946 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fbe2150 to
acdd13e
Compare
|
Landed via temp rebase onto main.
Thanks @scoootscooob! |
…penclaw#31996) * fix(cron): move session reaper to finally block so it runs reliably The cron session reaper was placed inside the try block of onTimer(), after job execution and state updates. If the locked persist section threw, the reaper was skipped — causing isolated cron run sessions to accumulate indefinitely in sessions.json. Move the reaper into the finally block so it always executes after a timer tick, regardless of whether job execution succeeded. The reaper is already self-throttled (MIN_SWEEP_INTERVAL_MS = 5 min) so calling it more reliably has no performance impact. Closes openclaw#31946 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: strengthen cron reaper failure-path coverage and changelog (openclaw#31996) (thanks @scoootscooob) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Peter Steinberger <steipete@gmail.com>
…penclaw#31996) * fix(cron): move session reaper to finally block so it runs reliably The cron session reaper was placed inside the try block of onTimer(), after job execution and state updates. If the locked persist section threw, the reaper was skipped — causing isolated cron run sessions to accumulate indefinitely in sessions.json. Move the reaper into the finally block so it always executes after a timer tick, regardless of whether job execution succeeded. The reaper is already self-throttled (MIN_SWEEP_INTERVAL_MS = 5 min) so calling it more reliably has no performance impact. Closes openclaw#31946 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: strengthen cron reaper failure-path coverage and changelog (openclaw#31996) (thanks @scoootscooob) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Peter Steinberger <steipete@gmail.com>
…penclaw#31996) * fix(cron): move session reaper to finally block so it runs reliably The cron session reaper was placed inside the try block of onTimer(), after job execution and state updates. If the locked persist section threw, the reaper was skipped — causing isolated cron run sessions to accumulate indefinitely in sessions.json. Move the reaper into the finally block so it always executes after a timer tick, regardless of whether job execution succeeded. The reaper is already self-throttled (MIN_SWEEP_INTERVAL_MS = 5 min) so calling it more reliably has no performance impact. Closes openclaw#31946 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: strengthen cron reaper failure-path coverage and changelog (openclaw#31996) (thanks @scoootscooob) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Peter Steinberger <steipete@gmail.com>
…penclaw#31996) * fix(cron): move session reaper to finally block so it runs reliably The cron session reaper was placed inside the try block of onTimer(), after job execution and state updates. If the locked persist section threw, the reaper was skipped — causing isolated cron run sessions to accumulate indefinitely in sessions.json. Move the reaper into the finally block so it always executes after a timer tick, regardless of whether job execution succeeded. The reaper is already self-throttled (MIN_SWEEP_INTERVAL_MS = 5 min) so calling it more reliably has no performance impact. Closes openclaw#31946 * fix: strengthen cron reaper failure-path coverage and changelog (openclaw#31996) (thanks @scoootscooob) --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
Summary
tryblock ofonTimer(), after job execution — if the locked persist section threw, the reaper was skipped entirelysessions.json, growing to 1000+ entries with massive token wastefinallyblock so it always executes after a timer tick, regardless of job execution outcomeMIN_SWEEP_INTERVAL_MS = 5 min) so calling it more reliably has no performance impactTest plan
resolveSessionStorePathis invoked to build reaper store pathstsgo)Closes #31946
🤖 Generated with Claude Code