
























@@ -663,6 +663,12 @@ export async function runShortTermDreamingPromotionIfTriggered(params: {
663663664664export function registerShortTermPromotionDreaming(api: OpenClawPluginApi): void {
665665let resolveStartupCron: (() => CronServiceLike | null) | null = null;
666+// Hold a live reference to the gateway context so we can retry cron resolution at runtime.
667+// The startup capture may fail if the cron service isn't available yet (race condition in
668+// startGatewaySidecars — the startup event fires via setTimeout(250ms) before deps.cron is
669+// attached). By keeping the context, we can call getCron() again on later reconciliation
670+// attempts when the service is guaranteed to be ready. Fixes #67362.
671+let gatewayContext: { getCron?: () => CronServiceLike | null } | null = null;
666672let unavailableCronWarningEmitted = false;
667673let lastRuntimeReconcileAtMs = 0;
668674let lastRuntimeConfigKey: string | null = null;
@@ -707,7 +713,22 @@ export function registerShortTermPromotionDreaming(api: OpenClawPluginApi): void
707713if (params.reason === "startup") {
708714resolveStartupCron = params.startupCron ?? null;
709715}
710-const cron = resolveStartupCron?.() ?? null;
716+let cron = resolveStartupCron?.() ?? null;
717+// Runtime fallback: retry resolving the cron service from the gateway context.
718+// This handles the case where the cron service was not yet available during
719+// gateway_start (250ms deferred init race in startGatewaySidecars) but is
720+// available now. Fixes #67362.
721+if (!cron && params.reason === "runtime" && gatewayContext) {
722+try {
723+cron = resolveCronServiceFromGatewayContext(gatewayContext);
724+if (cron) {
725+// Refresh the startup capture so subsequent calls resolve immediately.
726+resolveStartupCron = () => cron;
727+}
728+} catch {
729+// Ignore — fall through with cron = null
730+}
731+}
711732const configKey = runtimeConfigKey(config);
712733if (!cron && config.enabled && !unavailableCronWarningEmitted) {
713734// Avoid a noisy startup-path warning when the gateway has not exposed cron yet.
@@ -751,6 +772,8 @@ export function registerShortTermPromotionDreaming(api: OpenClawPluginApi): void
751772};
752773753774api.on("gateway_start", async (_event, ctx) => {
775+// Store the gateway context for runtime cron resolution retries.
776+gatewayContext = ctx as unknown as { getCron?: () => CronServiceLike | null };
754777try {
755778await reconcileManagedDreamingCron({
756779reason: "startup",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。