惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
C
Check Point Blog
J
Java Code Geeks
腾讯CDC
Apple Machine Learning Research
Apple Machine Learning Research
宝玉的分享
宝玉的分享
Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
量子位
Google DeepMind News
Google DeepMind News
I
InfoQ
The GitHub Blog
The GitHub Blog
aimingoo的专栏
aimingoo的专栏
N
Netflix TechBlog - Medium
Hugging Face - Blog
Hugging Face - Blog
博客园 - Franky
V
V2EX
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
小众软件
小众软件
博客园_首页
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
IT之家
IT之家

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(update): require applied gateway restarts · openclaw/...
IAMSamuelRod · 2026-04-27 · via Recent Commits to openclaw:main

@@ -9,6 +9,7 @@ const consumeGatewaySigusr1RestartAuthorization = vi.fn(() => true);

99

const consumeGatewayRestartIntentSync = vi.fn(() => false);

1010

const isGatewaySigusr1RestartExternallyAllowed = vi.fn(() => false);

1111

const markGatewaySigusr1RestartHandled = vi.fn();

12+

const peekGatewaySigusr1RestartReason = vi.fn<() => string | undefined>(() => undefined);

1213

const scheduleGatewaySigusr1Restart = vi.fn((_opts?: { delayMs?: number; reason?: string }) => ({

1314

ok: true,

1415

pid: process.pid,

@@ -30,6 +31,17 @@ const waitForBundledRuntimeDepsInstallIdle = vi.fn(async (_timeoutMs?: number) =

3031

const restartGatewayProcessWithFreshPid = vi.fn<

3132

() => { mode: "spawned" | "supervised" | "disabled" | "failed"; pid?: number; detail?: string }

3233

>(() => ({ mode: "disabled" }));

34+

const respawnGatewayProcessForUpdate = vi.fn<

35+

() => {

36+

mode: "spawned" | "supervised" | "disabled" | "failed";

37+

pid?: number;

38+

detail?: string;

39+

child?: { kill: () => void };

40+

}

41+

>(() => ({ mode: "disabled", detail: "OPENCLAW_NO_RESPAWN" }));

42+

const markUpdateRestartSentinelFailure = vi.fn<(reason: string) => Promise<null>>(

43+

async (_reason: string) => null,

44+

);

3345

const abortEmbeddedPiRun = vi.fn(

3446

(_sessionId?: string, _opts?: { mode?: "all" | "compacting" }) => false,

3547

);

@@ -58,14 +70,20 @@ vi.mock("../../infra/restart.js", () => ({

5870

consumeGatewayRestartIntentSync: () => consumeGatewayRestartIntentSync(),

5971

isGatewaySigusr1RestartExternallyAllowed: () => isGatewaySigusr1RestartExternallyAllowed(),

6072

markGatewaySigusr1RestartHandled: () => markGatewaySigusr1RestartHandled(),

73+

peekGatewaySigusr1RestartReason: () => peekGatewaySigusr1RestartReason(),

6174

scheduleGatewaySigusr1Restart: (opts?: { delayMs?: number; reason?: string }) =>

6275

scheduleGatewaySigusr1Restart(opts),

6376

}));

64776578

vi.mock("../../infra/process-respawn.js", () => ({

79+

respawnGatewayProcessForUpdate: () => respawnGatewayProcessForUpdate(),

6680

restartGatewayProcessWithFreshPid: () => restartGatewayProcessWithFreshPid(),

6781

}));

688283+

vi.mock("../../infra/restart-sentinel.js", () => ({

84+

markUpdateRestartSentinelFailure: (reason: string) => markUpdateRestartSentinelFailure(reason),

85+

}));

86+6987

vi.mock("../../process/command-queue.js", () => ({

7088

getActiveTaskCount: () => getActiveTaskCount(),

7189

markGatewayDraining: () => markGatewayDraining(),

@@ -195,13 +213,17 @@ async function runLoopWithStart(params: {

195213

start: ReturnType<typeof vi.fn>;

196214

runtime: LoopRuntime;

197215

lockPort?: number;

216+

healthHost?: string;

217+

waitForHealthyChild?: (port: number, pid?: number, host?: string) => Promise<boolean>;

198218

}) {

199219

vi.resetModules();

200220

const { runGatewayLoop } = await import("./run-loop.js");

201221

const loopPromise = runGatewayLoop({

202222

start: params.start as unknown as Parameters<typeof runGatewayLoop>[0]["start"],

203223

runtime: params.runtime,

204224

lockPort: params.lockPort,

225+

healthHost: params.healthHost,

226+

waitForHealthyChild: params.waitForHealthyChild,

205227

});

206228

return { loopPromise };

207229

}

@@ -292,6 +314,12 @@ describe("runGatewayLoop", () => {

292314

},

293315

},

294316

});

317+

peekGatewaySigusr1RestartReason.mockReturnValue(undefined);

318+

respawnGatewayProcessForUpdate.mockReturnValue({

319+

mode: "disabled",

320+

detail: "OPENCLAW_NO_RESPAWN",

321+

});

322+

markUpdateRestartSentinelFailure.mockClear();

295323296324

await withIsolatedSignals(async ({ captureSignal }) => {

297325

getActiveTaskCount.mockReturnValueOnce(2).mockReturnValueOnce(0);

@@ -453,6 +481,7 @@ describe("runGatewayLoop", () => {

453481454482

it("releases the lock before exiting on spawned restart", async () => {

455483

vi.clearAllMocks();

484+

peekGatewaySigusr1RestartReason.mockReturnValue(undefined);

456485457486

await withIsolatedSignals(async ({ captureSignal }) => {

458487

const lockRelease = vi.fn(async () => {});

@@ -484,6 +513,7 @@ describe("runGatewayLoop", () => {

484513485514

it("waits briefly before exiting on launchd supervised restart", async () => {

486515

vi.clearAllMocks();

516+

peekGatewaySigusr1RestartReason.mockReturnValue(undefined);

487517

try {

488518

setPlatform("darwin");

489519

process.env.LAUNCH_JOB_LABEL = "ai.openclaw.gateway";

@@ -511,6 +541,7 @@ describe("runGatewayLoop", () => {

511541512542

it("forwards lockPort to initial and restart lock acquisitions", async () => {

513543

vi.clearAllMocks();

544+

peekGatewaySigusr1RestartReason.mockReturnValue(undefined);

514545515546

await withIsolatedSignals(async ({ captureSignal }) => {

516547

const closeFirst = vi.fn(async () => {});

@@ -549,6 +580,7 @@ describe("runGatewayLoop", () => {

549580550581

it("exits when lock reacquire fails during in-process restart fallback", async () => {

551582

vi.clearAllMocks();

583+

peekGatewaySigusr1RestartReason.mockReturnValue(undefined);

552584553585

await withIsolatedSignals(async ({ captureSignal }) => {

554586

const lockRelease = vi.fn(async () => {});

@@ -574,6 +606,103 @@ describe("runGatewayLoop", () => {

574606

);

575607

});

576608

});

609+610+

it("hard-respawns update restarts and exits only after the replacement becomes healthy", async () => {

611+

vi.clearAllMocks();

612+

peekGatewaySigusr1RestartReason.mockReturnValue("update.run");

613+

respawnGatewayProcessForUpdate.mockReturnValueOnce({

614+

mode: "spawned",

615+

pid: 7777,

616+

child: { kill: vi.fn() },

617+

});

618+619+

await withIsolatedSignals(async ({ captureSignal }) => {

620+

const waitForHealthyChild = vi.fn(async () => true);

621+

const close = vi.fn(async () => {});

622+

const { start, started } = createSignaledStart(close);

623+

const { runtime, exited } = createRuntimeWithExitSignal();

624+

await runLoopWithStart({ start, runtime, lockPort: 18789, waitForHealthyChild });

625+

await waitForStart(started);

626+

const sigusr1 = captureSignal("SIGUSR1");

627+628+

sigusr1();

629+630+

await expect(exited).resolves.toBe(0);

631+

expect(waitForHealthyChild).toHaveBeenCalledWith(18789, 7777, "127.0.0.1");

632+

expect(respawnGatewayProcessForUpdate).toHaveBeenCalledTimes(1);

633+

expect(start).toHaveBeenCalledTimes(1);

634+

expect(markUpdateRestartSentinelFailure).not.toHaveBeenCalled();

635+

});

636+

});

637+638+

it("probes the configured gateway host for update respawn health", async () => {

639+

vi.clearAllMocks();

640+

peekGatewaySigusr1RestartReason.mockReturnValue("update.run");

641+

respawnGatewayProcessForUpdate.mockReturnValueOnce({

642+

mode: "spawned",

643+

pid: 7778,

644+

child: { kill: vi.fn() },

645+

});

646+647+

await withIsolatedSignals(async ({ captureSignal }) => {

648+

const waitForHealthyChild = vi.fn(async () => true);

649+

const close = vi.fn(async () => {});

650+

const { start, started } = createSignaledStart(close);

651+

const { runtime, exited } = createRuntimeWithExitSignal();

652+

await runLoopWithStart({

653+

start,

654+

runtime,

655+

lockPort: 18789,

656+

healthHost: "10.0.0.25",

657+

waitForHealthyChild,

658+

});

659+

await waitForStart(started);

660+

const sigusr1 = captureSignal("SIGUSR1");

661+662+

sigusr1();

663+664+

await expect(exited).resolves.toBe(0);

665+

expect(waitForHealthyChild).toHaveBeenCalledWith(18789, 7778, "10.0.0.25");

666+

});

667+

});

668+669+

it("marks update respawn failures and falls back to in-process restart", async () => {

670+

vi.clearAllMocks();

671+

peekGatewaySigusr1RestartReason.mockReturnValue("update.run");

672+

const kill = vi.fn();

673+

respawnGatewayProcessForUpdate.mockReturnValueOnce({

674+

mode: "spawned",

675+

pid: 8888,

676+

child: { kill },

677+

});

678+679+

await withIsolatedSignals(async ({ captureSignal }) => {

680+

const waitForHealthyChild = vi.fn(async () => false);

681+

const closeFirst = vi.fn(async () => {});

682+

const closeSecond = vi.fn(async () => {});

683+

const { runtime, exited } = createRuntimeWithExitSignal();

684+

const start = vi

685+

.fn()

686+

.mockResolvedValueOnce({ close: closeFirst })

687+

.mockResolvedValueOnce({ close: closeSecond });

688+689+

await runLoopWithStart({ start, runtime, lockPort: 18789, waitForHealthyChild });

690+

await new Promise<void>((resolve) => setImmediate(resolve));

691+

const sigusr1 = captureSignal("SIGUSR1");

692+

const sigterm = captureSignal("SIGTERM");

693+694+

sigusr1();

695+

await new Promise<void>((resolve) => setImmediate(resolve));

696+697+

expect(waitForHealthyChild).toHaveBeenCalledWith(18789, 8888, "127.0.0.1");

698+

expect(kill).toHaveBeenCalledTimes(1);

699+

expect(markUpdateRestartSentinelFailure).toHaveBeenCalledWith("restart-unhealthy");

700+

expect(start).toHaveBeenCalledTimes(2);

701+702+

sigterm();

703+

await expect(exited).resolves.toBe(0);

704+

});

705+

});

577706

});

578707579708

describe("gateway discover routing helpers", () => {