Cron: drain pending writes before reading run log#25416
Merged
Takhoffman merged 2 commits intoopenclaw:mainfrom Mar 1, 2026
Merged
Cron: drain pending writes before reading run log#25416Takhoffman merged 2 commits intoopenclaw:mainfrom
Takhoffman merged 2 commits intoopenclaw:mainfrom
Conversation
hwb96
pushed a commit
to hwb96/openclaw
that referenced
this pull request
Mar 1, 2026
* Cron: drain pending writes before reading run log * Retrigger CI
github-actions bot
pushed a commit
to tankerwng2/openclaw
that referenced
this pull request
Mar 1, 2026
* Cron: drain pending writes before reading run log * Retrigger CI
zooqueen
added a commit
to hanzoai/bot
that referenced
this pull request
Mar 1, 2026
Cherry-pick of upstream 0cc4658.
ansh
pushed a commit
to vibecode/openclaw
that referenced
this pull request
Mar 2, 2026
* Cron: drain pending writes before reading run log * Retrigger CI
steipete
pushed a commit
to Sid-Qin/openclaw
that referenced
this pull request
Mar 2, 2026
* Cron: drain pending writes before reading run log * Retrigger CI
safzanpirani
pushed a commit
to safzanpirani/clawdbot
that referenced
this pull request
Mar 2, 2026
* Cron: drain pending writes before reading run log * Retrigger CI
steipete
pushed a commit
to Sid-Qin/openclaw
that referenced
this pull request
Mar 2, 2026
* Cron: drain pending writes before reading run log * Retrigger CI
robertchang-ga
pushed a commit
to robertchang-ga/openclaw
that referenced
this pull request
Mar 2, 2026
* Cron: drain pending writes before reading run log * Retrigger CI
hanqizheng
pushed a commit
to hanqizheng/openclaw
that referenced
this pull request
Mar 2, 2026
* Cron: drain pending writes before reading run log * Retrigger CI
execute008
pushed a commit
to execute008/openclaw
that referenced
this pull request
Mar 2, 2026
* Cron: drain pending writes before reading run log * Retrigger CI
dorgonman
pushed a commit
to kanohorizonia/openclaw
that referenced
this pull request
Mar 3, 2026
* Cron: drain pending writes before reading run log * Retrigger CI
sachinkundu
pushed a commit
to sachinkundu/openclaw
that referenced
this pull request
Mar 6, 2026
* Cron: drain pending writes before reading run log * Retrigger CI
zooqueen
added a commit
to hanzoai/bot
that referenced
this pull request
Mar 6, 2026
Cherry-pick of upstream 0cc4658.
zooqueen
pushed a commit
to hanzoai/bot
that referenced
this pull request
Mar 6, 2026
* Cron: drain pending writes before reading run log * Retrigger CI
Mateljan1
pushed a commit
to Mateljan1/openclaw
that referenced
this pull request
Mar 7, 2026
* Cron: drain pending writes before reading run log * Retrigger CI
alexey-pelykh
pushed a commit
to remoteclaw/remoteclaw
that referenced
this pull request
Mar 16, 2026
* Cron: drain pending writes before reading run log * Retrigger CI (cherry picked from commit 0cc4658)
alexey-pelykh
added a commit
to remoteclaw/remoteclaw
that referenced
this pull request
Mar 16, 2026
…1519) * Cron: drain pending writes before reading run log * Retrigger CI (cherry picked from commit 0cc4658) Co-authored-by: Aleksandrs Tihenko <[email protected]>
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
cron runsreturns empty results becauseappendCronRunLoginserver-cron.tsis fire-and-forget (void). Reads can race with in-flight writes.readCronRunLogEntries,readCronRunLogEntriesPage,readCronRunLogEntriesPageAll) now drain any pending write for the target file(s) before reading.server-cron.tsstays fire-and-forget (no async change needed in the event callback). No changes to write serialization, pruning, or file format.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
openclaw cron runsnow reliably shows recent run entries that were written moments before the read. Previously these could appear missing due to write/read race.Security Impact (required)
Repro + Verification
Environment
Steps
*/5 * * * *)npx openclaw cron runs --id <job-id> --limit 3shortly after a cron firesExpected
Actual
Evidence
appendCronRunLog, then reads and asserts the entry is visiblepnpm checkcleanHuman Verification (required)
readCronRunLogEntriesPageAlldrains all file paths, drain on file with no pending write is a no-opwritesByPathserialization queue is unchanged)Compatibility / Migration
Failure Recovery (if this breaks)
Risks and Mitigations
Greptile Summary
This PR fixes a race condition where
openclaw cron runsreturns empty results because fire-and-forget writes fromappendCronRunLogcan be in-flight when reads occur. The fix adds adrainPendingWritehelper that awaits any pending write promise for a file before reading it.drainPendingWritefunction insrc/cron/run-log.ts:106-112that checks thewritesByPathMap for pending writes and awaits themreadCronRunLogEntries,readCronRunLogEntriesPage,readCronRunLogEntriesPageAll) to drain pending writes before reading filesThe implementation is minimal and focused - it only modifies the read path to wait for writes, without changing the existing write serialization queue or the fire-and-forget pattern used in
server-cron.ts:297.Confidence Score: 5/5
drainPendingWritefunction correctly reuses the existingwritesByPathserialization queue without modifying write behavior. The test directly validates the fix scenario (fire-and-forget write followed by immediate read). All existing tests pass, demonstrating backward compatibility. The worst-case performance impact (read blocked by slow write) is mitigated by the fact that writes are fast appends with infrequent pruning.Last reviewed commit: cc4504b