openclaw - ✅(Solved) Fix [Bug]: [Bug] gateway start resets Scheduled Task logon/privilege settings + gateway restart hangs on Windows (2026.3.31) [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#59271Fetched 2026-04-08 02:26:40
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×2labeled ×2closed ×1locked ×1

openclaw gateway start resets Scheduled Task logon/privilege settings and gateway restart hangs on Windows

Root Cause

openclaw gateway start resets Scheduled Task logon/privilege settings and gateway restart hangs on Windows

Fix Action

Fixed

PR fix notes

PR #59335: fix(daemon): preserve Windows Task Scheduler settings on reinstall and exit early on failed restart

Description (problem / solution / changelog)

Summary

  • Problem: openclaw gateway install uses schtasks /Create /F which resets user-configured Task Scheduler settings (run level, logon type, privileges) on every reinstall. openclaw gateway restart hangs ~60s when the gateway fails to start.
  • Why it matters: Windows users who configure elevated privileges via Task Scheduler UI lose their settings on every install/upgrade. The restart hang makes the CLI appear frozen.
  • What changed: activateScheduledTask now uses schtasks /Change /TR when the task already exists, preserving all other settings. waitForGatewayHealthyRestart exits early after ~3s when the task is clearly stopped and the port is free.
  • What did NOT change (scope boundary): New task creation still uses /Create /F. Restart health check timeout, retry logic, and stale PID handling are unchanged.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • 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

  • Closes #59271
  • This PR fixes a bug or regression

Root Cause / Regression History (if applicable)

  • Root cause: activateScheduledTask unconditionally uses schtasks /Create /F which overwrites all task properties. The post-restart health loop has no early exit for a clearly-dead gateway.
  • Missing detection / guardrail: No test asserted that existing task settings survive a reinstall. No early exit condition in the health loop for stopped+free state.
  • Prior context: The /Create /F pattern has been present since the original schtasks implementation. The health loop timeout (60s) was designed for slow VM startups but has no fast-fail path.
  • Why this regressed now: Not a regression per se — the settings-reset was always present but became more visible as users customized task privileges. The restart hang became noticeable after hardened stop/cleanup logic (commit 5ea03efe92) added more sequential waits.
  • If unknown, what was ruled out: N/A

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/daemon/schtasks.install.test.ts
  • Scenario the test should lock in: When task already exists (mock returns code 0), install uses /Change not /Create /F.
  • Why this is the smallest reliable guardrail: Verifies the schtasks command sequence without requiring a real Windows Task Scheduler.
  • Existing test that already covers this (if any): Updated existing writes quoted set assignments and escapes metacharacters test to assert /Change path.
  • If no new test is added, why not: Existing test was updated. Early exit in health loop is covered by existing restart-health.test.ts passing (no false early exits).

User-visible / Behavior Changes

  • openclaw gateway install --force no longer resets Task Scheduler run level, logon type, or privileges on existing tasks.
  • openclaw gateway restart exits in ~3s instead of ~60s when the gateway fails to start.

Diagram (if applicable)

Before (install):
[gateway install] -> [schtasks /Create /F] -> all task settings reset

After (install):
[gateway install] -> [task exists?] --yes--> [schtasks /Change /TR] -> settings preserved
                                    --no---> [schtasks /Create /F]  -> new task created

Before (restart):
[gateway restart] -> [task stopped + port free] -> wait 60s -> timeout error

After (restart):
[gateway restart] -> [task stopped + port free x6] -> bail after ~3s -> timeout error

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No (same schtasks binary, different subcommand)
  • Data access scope changed? No

Repro + Verification

Environment

  • OS: Windows 11 Home
  • Runtime/container: Node.js 24.x, npm global install
  • Model/provider: any
  • Integration/channel: N/A
  • Relevant config: default gateway config with Windows Scheduled Task

Steps

  1. openclaw gateway install — task created
  2. Open Task Scheduler UI, change task to "Run whether user is logged on or not" with elevated privileges
  3. openclaw gateway install --force

Expected

  • Task settings (logon type, run level) preserved after step 3

Actual (before fix)

  • Task settings reset to defaults (Run only when logged on, LIMITED)

Evidence

  • Failing test/log before + passing after
    • schtasks.install.test.ts updated to verify /Change path; all 43 tests pass across schtasks.install, schtasks.stop, restart-health, and lifecycle suites.

Human Verification (required)

  • Verified scenarios: All related test suites pass (43 tests). TypeScript type-check passes with no errors in changed files.
  • Edge cases checked: /Change failure falls back to /Create /F. Health loop early exit requires 6 consecutive stopped+free checks (not a single flap).
  • What you did not verify: Manual testing on Windows (no Windows environment available). Real schtasks behavior with /Change /TR.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Risks and Mitigations

  • Risk: schtasks /Change may behave differently across Windows editions (Home vs Pro vs Server) or locales.
    • Mitigation: Falls back to /Create /F if /Change fails, preserving original behavior.
  • Risk: Early exit in health loop could bail prematurely if task status briefly reports "stopped" during startup.
    • Mitigation: Requires 6 consecutive stopped+free checks (~3s), giving the task scheduler time to transition.

Changed files

  • src/channels/plugins/contracts/channel-import-guardrails.test.ts (modified, +2/-0)
  • src/cli/daemon-cli/restart-health.ts (modified, +27/-0)
  • src/daemon/schtasks.install.test.ts (modified, +50/-3)
  • src/daemon/schtasks.startup-fallback.test.ts (modified, +2/-0)
  • src/daemon/schtasks.ts (modified, +37/-0)
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

openclaw gateway start resets Scheduled Task logon/privilege settings and gateway restart hangs on Windows

Steps to reproduce

  1. Install OpenClaw 2026.3.31 via npm on Windows 11
  2. Run: openclaw gateway install --force
  3. Manually set Task Scheduler: "Run whether user is logged on or not" + "Run with highest privileges"
  4. Run: openclaw gateway start
  5. Observe Task Scheduler settings reverted to "Run only when user is logged on" and highest privileges unchecked
  6. For Bug 2: run openclaw gateway restart — command hangs indefinitely

Expected behavior

gateway start should preserve existing Scheduled Task settings. gateway restart should complete without hanging.

Actual behavior

gateway start resets logon mode and privilege level on every run. gateway restart never completes on Windows.

OpenClaw version

2026.3.31 (213a704)

Operating system

Windows 11 Home

Install method

npm global

Model

NOT_ENOUGH_INFO

Provider / routing chain

NOT_ENOUGH_INFO

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

OS: Windows 11 Home OpenClaw: 2026.3.31 (213a704) Node.js: 24.14.1 Installation: npm global, Windows Scheduled Task Last known good version: 2026.3.24

extent analysis

TL;DR

Reverting to OpenClaw version 2026.3.24 may resolve the issue with the gateway start resetting Scheduled Task logon/privilege settings and the gateway restart hanging on Windows.

Guidance

  • Verify that the issue is specific to OpenClaw version 2026.3.31 by testing with the last known good version, 2026.3.24.
  • Check the Node.js version compatibility with OpenClaw, as the issue might be related to the Node.js version 24.14.1.
  • Investigate the Scheduled Task settings after running openclaw gateway start to understand what specifically is being reset.
  • Consider testing the openclaw gateway restart command with a clean installation of OpenClaw 2026.3.24 to isolate the issue.

Example

No code snippet is provided as the issue does not imply a specific code-related fix.

Notes

The provided information does not include detailed logs or error messages, which might be necessary for a more accurate diagnosis. Additionally, the issue might be specific to the Windows 11 Home operating system or the npm global installation method.

Recommendation

Apply workaround: Revert to OpenClaw version 2026.3.24, as it is mentioned as the last known good version, to potentially resolve the issues with gateway start and restart.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

gateway start should preserve existing Scheduled Task settings. gateway restart should complete without hanging.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING