Skip to content

fix(memory-core): suppress startup "cron service unavailable" warning (closes #69939) - #69941

Merged
steipete merged 2 commits into
openclaw:mainfrom
Sanjays2402:fix/memory-core-startup-cron-warning
Apr 22, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
Sanjays2402:fix/memory-core-startup-cron-warning

Conversation

@Sanjays2402

Copy link
Copy Markdown
Contributor

Closes #69939.

Bug

On every gateway startup, memory-core logs:

memory-core: managed dreaming cron could not be reconciled (cron service unavailable).

The warning fires once (guarded by unavailableCronWarningEmitted), but recurs on every cold/warm restart. The managed dreaming cron job itself runs correctly — this is purely a log-noise regression, not a functional failure.

Root cause

In src/plugins/core/server.impl the gateway:startup event is emitted via a deferred setTimeout (~250ms). deps.cron is not yet attached to the event context when memory-core's startup hook runs, so resolveCronServiceFromStartupSource(startupCronSource) → source.context.cron ?? source.deps?.cron returns null on the first invocation. reconcileManagedDreamingCron() then emits the warning on the startup path, even though the cron service comes up seconds later and the runtime heartbeat reconciliation path successfully attaches the job.

Reporter's diagnosis and reproduction steps are in the issue (thanks @mlaihk).

Fix — Option A (minimally invasive)

In reconcileManagedDreamingCron(), only emit the warn when the function is called from the runtime reconciliation path (before_agent_reply heartbeat). On the startup path with cron == null, demote the message to logger.debug and leave the unavailableCronWarningEmitted flag unset so that if cron genuinely fails to initialize, the next runtime reconciliation still warns.

This preserves the existing "cron service is actually missing" signal — we only silence the known startup race.

Before

const cron = resolveCronServiceFromStartupSource(startupCronSource);
if (!cron && config.enabled && !unavailableCronWarningEmitted) {
  api.logger.warn(
    "memory-core: managed dreaming cron could not be reconciled (cron service unavailable).",
  );
  unavailableCronWarningEmitted = true;
}

After

const cron = resolveCronServiceFromStartupSource(startupCronSource);
if (!cron && config.enabled && !unavailableCronWarningEmitted) {
  // The gateway emits `gateway:startup` via a deferred setTimeout, and
  // `deps.cron` may not be attached yet when memory-core's startup hook fires
  // (see issue #69939). Avoid logging a confusing warning on the startup path —
  // the runtime reconciliation path (heartbeat-driven) will still warn if the
  // cron service remains unavailable after boot.
  if (params.reason === "startup") {
    api.logger.debug?.(
      "memory-core: cron service not yet available at gateway:startup; deferring to runtime reconciliation.",
    );
  } else {
    api.logger.warn(
      "memory-core: managed dreaming cron could not be reconciled (cron service unavailable).",
    );
    unavailableCronWarningEmitted = true;
  }
}

Considered but rejected:

  • Option B (track cronServiceSeen): more state for the same observable behavior.
  • Option C (reorder startup so deps.cron is attached before emitting gateway:startup): correct fix long-term, but touches server.impl and the core startup sequencer — out of scope for a log-noise patch. Worth tracking separately.

Tests

Added to extensions/memory-core/src/dreaming.test.ts:

  1. does not emit the cron-unavailable warning on gateway:startup when deps.cron is missing (regression #69939) — reproduces the issue: fires gateway:startup with deps: {}, asserts logger.warn is never called with "cron service unavailable", and asserts the debug message is logged instead.
  2. still warns on runtime reconciliation when cron remains unavailable (preserves #69939 genuine-failure signal) — fires startup with no cron (silent), then a heartbeat before_agent_reply with no cron, and asserts the warning does fire — ensuring the genuine reconciliation-failure signal is preserved.

Also added debug: vi.fn() to the existing createLogger() test helper to observe the downgraded log.

Test run

Full memory-core suite (test/vitest/vitest.extension-memory.config.ts):

Test Files  47 passed (47)
     Tests  496 passed | 3 skipped (499)

Scope

  • 2 files changed, 121 insertions, 4 deletions.
  • No changes to server.impl, the 250ms startup setTimeout, or the cron service itself.
  • No changes to dist/.

@greptile-apps

greptile-apps Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a log-noise regression in memory-core where a "cron service unavailable" warning fired on every gateway startup due to a timing race between the deferred gateway:startup event and deps.cron attachment. The fix is minimal: in reconcileManagedDreamingCron, startup-path misses are demoted to debug (with the unavailableCronWarningEmitted flag left unset), preserving the genuine-failure warn on runtime heartbeat reconciliation. Two targeted regression tests are added to cover both the suppression and the preserved warning path.

Confidence Score: 5/5

Safe to merge — change is minimal, correctly scoped, and fully covered by new regression tests.

No P0 or P1 issues found. The fix accurately models the startup-race cause, the flag lifecycle is preserved correctly (unavailableCronWarningEmitted stays false on startup so the runtime path can still warn), and both the suppression and the genuine-failure paths are exercised by the new tests. Optional-chaining on debug?.() is appropriate for loggers that may not implement debug.

No files require special attention.

Reviews (1): Last reviewed commit: "fix(memory-core): suppress startup "cron..." | Re-trigger Greptile

Sanjays2402 and others added 2 commits April 22, 2026 04:46
…closes openclaw#69939)

memory-core registers a gateway:startup hook that runs reconcileManagedDreamingCron() before deps.cron is attached to the startup event (the startup hook is deferred via a 250ms setTimeout in server.impl).

Downgrade the first startup-time "cron service unavailable" warning to a debug log, and rely on the existing runtime reconciliation path to warn if the cron service truly stays unavailable after boot. The managed dreaming cron job itself runs correctly — this was a log-noise regression, not a functional failure.

Signed-off-by: Sanjay Santhanam <[email protected]>
@steipete
steipete force-pushed the fix/memory-core-startup-cron-warning branch from 3228dcf to fd281d3 Compare April 22, 2026 03:48
@steipete
steipete merged commit 11f38af into openclaw:main Apr 22, 2026
10 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Landed via rebase onto main.

Thanks @Sanjays2402!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fd281d393b

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +726 to +729
if (params.reason === "startup") {
api.logger.debug?.(
"memory-core: cron service not yet available at gateway:startup; deferring to runtime reconciliation.",
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Retain cron-unavailable warning when heartbeats are off

The new startup branch always demotes missing-cron to debug and does not set the warning flag, so the only remaining warn path is runtime reconciliation. In this plugin, runtime reconciliation is only reached from before_agent_reply when ctx.trigger === "heartbeat"; if heartbeats are disabled (or no heartbeat run happens after boot), a genuinely unavailable cron service is now silent forever. This regresses the stated “preserve genuine-failure signal” behavior for non-heartbeat environments.

Useful? React with 👍 / 👎.

@prtags

prtags Bot commented Apr 23, 2026

Copy link
Copy Markdown

Related work from PRtags group witty-dane-m34j

Title: Open PR duplicate: memory-core startup cron warning suppression

Number Title
#69941* fix(memory-core): suppress startup "cron service unavailable" warning (closes #69939)
#69983 fix(memory-core): suppress false cron unavailable warning on startup

* This PR

medikoo pushed a commit to medikoo/openclaw that referenced this pull request Apr 24, 2026
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
zhonghe0615 pushed a commit to zhonghe0615/openclaw that referenced this pull request May 7, 2026
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request May 13, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
Heetisk pushed a commit to Heetisk/openclaw that referenced this pull request Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: memory-core logs 'cron service unavailable' on every gateway startup (2026.4.20)

2 participants