mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 20:00:42 +00:00
fix(gateway): avoid stale running status from Windows Scheduled Task (openclaw#19504) thanks @Fologan
Verified: - pnpm vitest src/daemon/schtasks.test.ts - pnpm check - pnpm build Co-authored-by: Fologan <164580328+Fologan@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
@@ -2,7 +2,12 @@ import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { parseSchtasksQuery, readScheduledTaskCommand, resolveTaskScriptPath } from "./schtasks.js";
|
||||
import {
|
||||
deriveScheduledTaskRuntimeStatus,
|
||||
parseSchtasksQuery,
|
||||
readScheduledTaskCommand,
|
||||
resolveTaskScriptPath,
|
||||
} from "./schtasks.js";
|
||||
|
||||
describe("schtasks runtime parsing", () => {
|
||||
it.each(["Ready", "Running"])("parses %s status", (status) => {
|
||||
@@ -20,6 +25,46 @@ describe("schtasks runtime parsing", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("scheduled task runtime derivation", () => {
|
||||
it("treats Running + 0x41301 as running", () => {
|
||||
expect(
|
||||
deriveScheduledTaskRuntimeStatus({
|
||||
status: "Running",
|
||||
lastRunResult: "0x41301",
|
||||
}),
|
||||
).toEqual({ status: "running" });
|
||||
});
|
||||
|
||||
it("treats Running + decimal 267009 as running", () => {
|
||||
expect(
|
||||
deriveScheduledTaskRuntimeStatus({
|
||||
status: "Running",
|
||||
lastRunResult: "267009",
|
||||
}),
|
||||
).toEqual({ status: "running" });
|
||||
});
|
||||
|
||||
it("treats Running without last result as running", () => {
|
||||
expect(
|
||||
deriveScheduledTaskRuntimeStatus({
|
||||
status: "Running",
|
||||
}),
|
||||
).toEqual({ status: "running" });
|
||||
});
|
||||
|
||||
it("downgrades stale Running status when last result is not a running code", () => {
|
||||
expect(
|
||||
deriveScheduledTaskRuntimeStatus({
|
||||
status: "Running",
|
||||
lastRunResult: "0x0",
|
||||
}),
|
||||
).toEqual({
|
||||
status: "stopped",
|
||||
detail: "Task reports Running but Last Run Result=0x0; treating as stale runtime state.",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveTaskScriptPath", () => {
|
||||
it.each([
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user