Skip to content

Fix: cron run timeout and doctor discord, issue 28942 #29011

Closed
sahilsatralkar wants to merge 6 commits intoopenclaw:mainfrom
sahilsatralkar:fix/issue-28942-cron-run-timeout-and-doctor-discord
Closed

Fix: cron run timeout and doctor discord, issue 28942 #29011
sahilsatralkar wants to merge 6 commits intoopenclaw:mainfrom
sahilsatralkar:fix/issue-28942-cron-run-timeout-and-doctor-discord

Conversation

@sahilsatralkar
Copy link
Copy Markdown
Contributor

Summary

Describe the problem and fix in 2–5 bullets:

  • Problem: openclaw cron run always times out after 30000ms even when the gateway is healthy and the job is running
  • Why it matters: Users cannot manually run cron jobs for debugging/testing because the CLI times out before the job completes (which can take up to 10 minutes)
  • What changed: Changed the default timeout for cron run command from 30000ms to 600000ms (10 minutes) to match the actual job execution timeout
  • What did NOT change (scope boundary): Did not change the gateway-side timeout behavior, only the CLI client timeout

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

  • CLI now waits up to 10 minutes for cron run instead of timing out after 30 seconds
  • Default timeout is now 600000ms instead of 30000ms

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: macOS (tested locally)
  • Runtime: Node 22
  • Model/provider: N/A
  • Integration/channel (if any): N/A
  • Relevant config (redacted): N/A

Steps

  1. Start a gateway with a cron job configured
  2. Run openclaw cron run
  3. Observe that the command completes instead of timing out

Expected

  • Command completes successfully within 10 minutes

Actual

  • Command now uses 600000ms timeout instead of 30000ms

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Added test uses 10 minute timeout on cron run by default in src/cli/cron-cli.test.ts
  • Added test does not add empty default account for multi-account Discord without top-level values in src/commands/doctor-legacy-config.migrations.test.ts
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios:
    • Ran pnpm vitest run src/cli/cron-cli.test.ts - 26 tests pass
    • Ran pnpm vitest run src/commands/doctor-legacy-config.migrations.test.ts - 16 tests pass
    • Ran pnpm build - builds successfully
    • Ran pnpm format:check - all files formatted correctly
  • Edge cases checked:
    • Verified timeout value is correctly passed to gateway call
    • Verified --due flag still works correctly
    • Verified multi-account Discord config without top-level values doesn't create empty default account
  • What you did not verify:
    • Did not test with actual gateway running (no live environment)

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps: N/A

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly:
  • Files/config to restore:
    • src/cli/cron-cli/register.cron-simple.ts
  • Known bad symptoms reviewers should watch for:
    • CLI timeout errors when running cron run

Risks and Mitigations

List only real risks for this PR. Add/remove entries as needed. If none, write None.

  • Risk: None - the change only increases the CLI timeout to match the actual job execution timeout
    • Mitigation: N/A

Built using OpenCode with MiniMax M2.5

Build Script-

Implementation Plan: Issue #28942 - Fix cron run timeout and doctor --fix Discord multi-account bug

Overview

This plan addresses two bugs from issue #28942:

  1. Bug 1: openclaw cron run always times out after 30000ms even when gateway is healthy
  2. Bug 2: doctor --fix repeatedly corrupts multi-account Discord configuration by adding an empty "default" account

Prerequisites

  • Node.js 22+ or Bun installed
  • pnpm package manager
  • Git configured with access to the openclaw repository

Step-by-Step Implementation

Step 1: Establish Baseline - Run All Existing Tests

  • Task: Run the full test suite to establish a baseline before making changes
  • Command: pnpm test (or pnpm test:coverage for detailed coverage)
  • Expected: All existing tests should pass
  • Verification: Check test results for any pre-existing failures
  • Note: Document any failing tests before proceeding

Step 2: Run CI Pipeline Tests Locally

  • Task: Verify build, typecheck, and lint commands that CI runs
  • Commands:
    pnpm build          # Build the project
    pnpm tsgo          # TypeScript type checking
    pnpm format:check  # Format check
    pnpm lint          # Lint check
    pnpm check         # Full check (format + tsgo + lint)
  • Expected: All commands should succeed without errors
  • Verification: Each command exits with code 0

Step 3: Run Specific Cron CLI Tests

  • Task: Run existing cron CLI tests to establish a baseline
  • Command: pnpm vitest run src/cli/cron-cli.test.ts
  • Expected: All cron CLI tests pass
  • Verification: Test output shows no failures

Step 4: Run Doctor Legacy Config Tests

  • Task: Run existing doctor-legacy-config tests to establish baseline
  • Commands:
    pnpm vitest run src/commands/doctor-legacy-config.test.ts
    pnpm vitest run src/commands/doctor-legacy-config.migrations.test.ts
  • Expected: All doctor-legacy-config tests pass
  • Verification: Test output shows no failures

Bug 1 Fix: cron run timeout

Step 5: Add --timeout option to cron run command

  • Task: Add --timeout option to the cron run command with a longer default
  • File: src/cli/cron-cli/register.cron-simple.ts
  • Change: Add .option("--timeout <ms>", "Timeout in ms (default 600000)", "600000") to the cron run command
  • Code location: Line ~95, after the --due option
  • Verification:
    • Build succeeds: pnpm build
    • TypeScript check passes: pnpm tsgo

Step 6: Verify timeout fix with test

  • Task: Create or verify a test for the new timeout option
  • File: src/cli/cron-cli.test.ts
  • Test: Verify the timeout option is passed correctly to callGatewayFromCli
  • Command: pnpm vitest run src/cli/cron-cli.test.ts
  • Expected: Test passes with the new timeout option

Step 7: Commit Bug 1 Fix

  • Task: Commit the cron run timeout fix
  • Commit message: CLI: add --timeout option to cron run command
  • Files changed: src/cli/cron-cli/register.cron-simple.ts
  • Verification: git log shows the commit with correct message

Bug 2 Fix: doctor --fix Discord multi-account

Step 8: Add empty account guard in doctor-legacy-config

  • Task: Prevent adding empty default account when migrating Discord config
  • File: src/commands/doctor-legacy-config.ts
  • Change: Add a check to skip creating default account if it would be empty
  • Code location: After line 336 (after populating defaultAccount), add:
    if (Object.keys(defaultAccount).length === 0) {
      continue;
    }
  • Verification:
    • Build succeeds: pnpm build
    • TypeScript check passes: pnpm tsgo

Step 9: Add test for empty account guard

  • Task: Add a test to verify the empty account guard works
  • File: src/commands/doctor-legacy-config.migrations.test.ts
  • Test: Add test case for multi-account Discord config without top-level values
  • Test scenario:
    • Discord has multiple accounts (e.g., bot1, bot2)
    • No top-level config keys that need migration
    • Running migration should NOT create an empty default account
  • Command: pnpm vitest run src/commands/doctor-legacy-config.migrations.test.ts
  • Expected: New test passes

Step 10: Run doctor-legacy-config tests

  • Task: Verify all doctor-legacy-config tests still pass
  • Commands:
    pnpm vitest run src/commands/doctor-legacy-config.test.ts
    pnpm vitest run src/commands/doctor-legacy-config.migrations.test.ts
  • Expected: All tests pass
  • Verification: No test failures

Step 11: Commit Bug 2 Fix

  • Task: Commit the doctor --fix Discord multi-account fix
  • Commit message: Doctor: skip adding empty default account for multi-account Discord
  • Files changed: src/commands/doctor-legacy-config.ts
  • Verification: git log shows the commit with correct message

Integration Tests

Step 12: Run Full Test Suite

  • Task: Run full test suite after all changes
  • Command: pnpm test
  • Expected: All tests pass
  • Verification: No test failures in output

Step 13: Run Full CI Checks

  • Task: Run all CI checks locally
  • Commands:
    pnpm build
    pnpm check
    pnpm format:check
  • Expected: All checks pass
  • Verification: Each command exits with code 0

Step 14: Verify TypeScript Strict Mode

  • Task: Ensure no TypeScript errors introduced
  • Command: pnpm tsgo
  • Expected: No TypeScript errors
  • Verification: Output shows no errors

Final Steps

Step 15: Push Changes to Remote

  • Task: Push the feature branch to the remote repository
  • Command: git push -u origin <branch-name>
  • Expected: Branch pushed successfully
  • Verification: GitHub shows new branch

Summary of Changes

Step File Change
5 src/cli/cron-cli/register.cron-simple.ts Added --timeout option with default 600000ms
8 src/commands/doctor-legacy-config.ts Added guard to skip empty default account

Test Commands Reference

# Full test suite
pnpm test
# Individual test files
pnpm vitest run src/cli/cron-cli.test.ts
pnpm vitest run src/commands/doctor-legacy-config.test.ts
pnpm vitest run src/commands/doctor-legacy-config.migrations.test.ts
# Build and checks
pnpm build
pnpm check
pnpm tsgo
pnpm format:check
pnpm lint

Notes

  • The default timeout of 600000ms (10 minutes) matches the DEFAULT_JOB_TIMEOUT_MS in src/cron/service/timeout-policy.ts
  • The empty account guard prevents corruption of multi-account Discord configurations
  • All commits should follow the project's commit message conventions (action-oriented, concise)

@openclaw-barnacle openclaw-barnacle bot added cli CLI command changes commands Command implementations size: S labels Feb 27, 2026
Copy link
Copy Markdown

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

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: c8b8b27f35

ℹ️ 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-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Feb 27, 2026

Greptile Summary

Fixed CLI timeout for cron run command (30s → 10min to match gateway job execution timeout) and prevented doctor --fix from creating empty default accounts in multi-account Discord configs.

Key changes:

  • src/cli/cron-cli/register.cron-simple.ts: hardcoded 10-minute timeout for cron run to match DEFAULT_JOB_TIMEOUT_MS (600000ms)
  • src/commands/doctor-legacy-config.ts: added safety check to skip empty default account creation
  • Added comprehensive tests for both fixes

Technical notes:

  • Timeout change aligns with gateway-side DEFAULT_JOB_TIMEOUT_MS constant in src/cron/service/timeout-policy.ts
  • Doctor fix adds defensive check after populating defaultAccount to prevent edge cases

Confidence Score: 4/5

  • Safe to merge with one minor UX consideration about timeout configurability
  • Both fixes address real bugs with appropriate test coverage. The timeout change correctly aligns CLI with gateway defaults. The doctor fix adds a defensive safety check. One style suggestion about preserving user-provided timeout options.
  • No files require special attention

Last reviewed commit: c8b8b27

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
Copy Markdown

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

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: 576ed07987

ℹ️ 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".

- Remove magic value check that treated --timeout 30000 as default
- Now passes timeout through directly to preserve user intent
- Add tests for --timeout 30000 and --timeout 600000 scenarios
- Change default timeout test from 600000 to 30000ms (original behavior)
@sahilsatralkar sahilsatralkar force-pushed the fix/issue-28942-cron-run-timeout-and-doctor-discord branch from 576ed07 to 75a3f81 Compare February 27, 2026 18:35
@sahilsatralkar
Copy link
Copy Markdown
Contributor Author

Hi @steipete , CI "check" failed because of format issue in CONTRIBUTING.md file

@sahilsatralkar
Copy link
Copy Markdown
Contributor Author

Hi @cpojer , the labeler workflow is getting rate limited on my PR (#29011). Think this falls under JS Infra? Happy to PR a fix if it falls under JS Infra. Please let me know

@Takhoffman
Copy link
Copy Markdown
Contributor

Thanks for putting this together and including tests.

I’m closing this for now because the PR scope mixes an unrelated doctor migration change and does not deliver a clean, isolated cron timeout behavior change in implementation. We need this split into tightly scoped, verifiable fixes.

Appreciate the work and write-up.

@Takhoffman Takhoffman closed this Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes close:not-planned PR close reason commands Command implementations size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openclaw cron run always times out + doctor --fix breaks multi-account Discord

2 participants