fix: clean up session records and run logs on cron.remove (#46369)#712
Open
BingqingLyu wants to merge 6 commits intomainfrom
Open
fix: clean up session records and run logs on cron.remove (#46369)#712BingqingLyu wants to merge 6 commits intomainfrom
BingqingLyu wants to merge 6 commits intomainfrom
Conversation
…6369) When a cron job is deleted, only the job config was removed from jobs.json. The session records in sessions.json and the run log file remained, causing ghost sessions to appear in the Control UI. After removing the job config, asynchronously: 1. Delete matching session entries (cron:{jobId}:*) from sessions.json 2. Delete the run log file at {cronStoreDir}/runs/{jobId}.jsonl Cleanup failures are logged but do not block the removal response.
… path - Use Promise.allSettled so session cleanup and run log deletion are independent; a failure in one does not skip the other - Capture the removed job's agentId before filtering and pass it to resolveSessionStorePath so non-default-agent jobs clean the correct sessions.json
…sion-cleanup-46369
- Prefer resolveSessionStorePath(agentId) over static sessionStorePath
so multi-agent deployments clean the correct sessions.json
- Match both canonical key (cron:{jobId}) and run keys (cron:{jobId}:run:*)
to prevent ghost sessions from either key type
- Fix pre-existing oxfmt formatting in message-handler.ts
Introduced in bb06dc7 on main but never called, causing oxlint failure.
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
Fixes openclaw#46369 — when deleting a cron job via
cron.remove, only the job config was removed fromjobs.json. Session records insessions.jsonand the run log file remained, causing "ghost sessions" to appear in the Control UI dropdown.The fix: After removing the job config, asynchronously clean up:
cron:{jobId}:*fromsessions.jsonviaupdateSessionStore{cronStoreDir}/runs/{jobId}.jsonlviafs.unlinkCleanup runs outside the critical path — failures are logged but don't block the removal response.
Changes
src/cron/service/ops.ts: AddedcleanupRemovedJobArtifacts()called after successful job removalsrc/cron/service.remove-cleanup.test.ts: 2 new tests verifying session and run log cleanupTest plan
.jsonlfile is deleted after job removal