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

推荐订阅源

D
DataBreaches.Net
N
Netflix TechBlog - Medium
F
Fortinet All Blogs
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
宝玉的分享
宝玉的分享
Y
Y Combinator Blog
博客园 - 聂微东
WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog RSS Feed
小众软件
小众软件
The GitHub Blog
The GitHub Blog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
Microsoft Azure Blog
Microsoft Azure Blog
V
V2EX
B
Blog
H
Help Net Security
D
Docker
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
罗磊的独立博客
月光博客
月光博客
博客园 - 司徒正美

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: recover macos launchagent after updates · openclaw/o...
jonathanlind · 2026-05-04 · via Recent Commits to openclaw:main

@@ -1,13 +1,15 @@

11

import fs from "node:fs/promises";

22

import os from "node:os";

33

import path from "node:path";

4-

import { describe, expect, it } from "vitest";

4+

import { describe, expect, it, vi } from "vitest";

55

import {

66

buildGatewayInstallEntrypointCandidates as resolveGatewayInstallEntrypointCandidates,

77

resolveGatewayInstallEntrypoint,

88

} from "../../daemon/gateway-entrypoint.js";

99

import {

1010

collectMissingPluginInstallPayloads,

11+

recoverInstalledLaunchAgentAfterUpdate,

12+

recoverLaunchAgentAndRecheckGatewayHealth,

1113

resolvePostInstallDoctorEnv,

1214

shouldPrepareUpdatedInstallRestart,

1315

resolveUpdatedGatewayRestartPort,

@@ -234,3 +236,202 @@ describe("shouldUseLegacyProcessRestartAfterUpdate", () => {

234236

expect(shouldUseLegacyProcessRestartAfterUpdate({ updateMode: "unknown" })).toBe(true);

235237

});

236238

});

239+

describe("recoverInstalledLaunchAgentAfterUpdate", () => {

240+

it("re-bootstraps an installed-but-not-loaded macOS LaunchAgent after update", async () => {

241+

const service = {} as never;

242+

const serviceEnv = { OPENCLAW_PROFILE: "stomme" } as NodeJS.ProcessEnv;

243+

const recoveredEnv = { ...serviceEnv, OPENCLAW_PORT: "18790" } as NodeJS.ProcessEnv;

244+

const readState = vi.fn(async () => ({

245+

installed: true,

246+

loaded: false,

247+

running: false,

248+

env: recoveredEnv,

249+

command: null,

250+

runtime: { status: "unknown", missingSupervision: true },

251+

}));

252+

const recover = vi.fn(async () => ({

253+

result: "restarted" as const,

254+

loaded: true as const,

255+

message: "Gateway LaunchAgent was installed but not loaded; re-bootstrapped launchd service.",

256+

}));

257+258+

await expect(

259+

recoverInstalledLaunchAgentAfterUpdate({

260+

service,

261+

env: serviceEnv,

262+

deps: {

263+

platform: "darwin",

264+

readState: readState as never,

265+

recover: recover as never,

266+

},

267+

}),

268+

).resolves.toEqual({

269+

attempted: true,

270+

recovered: true,

271+

message: "Gateway LaunchAgent was installed but not loaded; re-bootstrapped launchd service.",

272+

});

273+274+

expect(readState).toHaveBeenCalledWith(service, { env: serviceEnv });

275+

expect(recover).toHaveBeenCalledWith({ result: "restarted", env: recoveredEnv });

276+

});

277+278+

it("does not touch non-macOS service managers", async () => {

279+

const readState = vi.fn();

280+

const recover = vi.fn();

281+282+

await expect(

283+

recoverInstalledLaunchAgentAfterUpdate({

284+

service: {} as never,

285+

deps: {

286+

platform: "linux",

287+

readState: readState as never,

288+

recover: recover as never,

289+

},

290+

}),

291+

).resolves.toEqual({ attempted: false, recovered: false });

292+293+

expect(readState).not.toHaveBeenCalled();

294+

expect(recover).not.toHaveBeenCalled();

295+

});

296+297+

it("does not recover a loaded LaunchAgent", async () => {

298+

const readState = vi.fn(async () => ({

299+

installed: true,

300+

loaded: true,

301+

running: true,

302+

env: { OPENCLAW_PROFILE: "stomme" } as NodeJS.ProcessEnv,

303+

command: null,

304+

runtime: { status: "running" },

305+

}));

306+

const recover = vi.fn();

307+308+

await expect(

309+

recoverInstalledLaunchAgentAfterUpdate({

310+

service: {} as never,

311+

deps: {

312+

platform: "darwin",

313+

readState: readState as never,

314+

recover: recover as never,

315+

},

316+

}),

317+

).resolves.toEqual({ attempted: false, recovered: false });

318+319+

expect(recover).not.toHaveBeenCalled();

320+

});

321+322+

it("returns an explicit failed recovery state when bootstrap repair fails", async () => {

323+

const readState = vi.fn(async () => ({

324+

installed: true,

325+

loaded: false,

326+

running: false,

327+

env: { OPENCLAW_PROFILE: "stomme" } as NodeJS.ProcessEnv,

328+

command: null,

329+

runtime: { status: "unknown", missingSupervision: true },

330+

}));

331+

const recover = vi.fn(async () => null);

332+333+

await expect(

334+

recoverInstalledLaunchAgentAfterUpdate({

335+

service: {} as never,

336+

deps: {

337+

platform: "darwin",

338+

readState: readState as never,

339+

recover: recover as never,

340+

},

341+

}),

342+

).resolves.toEqual({

343+

attempted: true,

344+

recovered: false,

345+

detail:

346+

"LaunchAgent was installed but not loaded; automatic bootstrap/kickstart recovery failed.",

347+

});

348+

});

349+

});

350+351+

describe("recoverLaunchAgentAndRecheckGatewayHealth", () => {

352+

it("does not report recovered update health until the gateway passes the post-recovery wait", async () => {

353+

const service = {} as never;

354+

const unhealthy = {

355+

runtime: { status: "stopped" },

356+

portUsage: { port: 18790, status: "free", listeners: [], hints: [] },

357+

healthy: false,

358+

staleGatewayPids: [],

359+

waitOutcome: "stopped-free",

360+

} as never;

361+

const healthy = {

362+

runtime: { status: "running", pid: 4242 },

363+

portUsage: { port: 18790, status: "busy", listeners: [{ pid: 4242 }], hints: [] },

364+

healthy: true,

365+

staleGatewayPids: [],

366+

gatewayVersion: "2026.5.3",

367+

waitOutcome: "healthy",

368+

} as never;

369+

const recoverLaunchAgent = vi.fn(async () => ({

370+

attempted: true as const,

371+

recovered: true as const,

372+

message: "Gateway LaunchAgent was installed but not loaded; re-bootstrapped launchd service.",

373+

}));

374+

const waitForHealthy = vi.fn(async () => healthy);

375+376+

await expect(

377+

recoverLaunchAgentAndRecheckGatewayHealth({

378+

health: unhealthy,

379+

service,

380+

port: 18790,

381+

expectedVersion: "2026.5.3",

382+

env: { OPENCLAW_PROFILE: "stomme", OPENCLAW_PORT: "18790" },

383+

deps: { recoverLaunchAgent, waitForHealthy },

384+

}),

385+

).resolves.toEqual({

386+

health: healthy,

387+

launchAgentRecovery: {

388+

attempted: true,

389+

recovered: true,

390+

message:

391+

"Gateway LaunchAgent was installed but not loaded; re-bootstrapped launchd service.",

392+

},

393+

});

394+395+

expect(waitForHealthy).toHaveBeenCalledWith({

396+

service,

397+

port: 18790,

398+

expectedVersion: "2026.5.3",

399+

env: { OPENCLAW_PROFILE: "stomme", OPENCLAW_PORT: "18790" },

400+

});

401+

});

402+403+

it("keeps the update unhealthy when LaunchAgent repair succeeds but health does not recover", async () => {

404+

const service = {} as never;

405+

const unhealthySnapshot = {

406+

runtime: { status: "stopped" },

407+

portUsage: { port: 18790, status: "free", listeners: [], hints: [] },

408+

healthy: false,

409+

staleGatewayPids: [],

410+

waitOutcome: "stopped-free",

411+

};

412+

const unhealthy = unhealthySnapshot as never;

413+

const stillUnhealthy = {

414+

...unhealthySnapshot,

415+

waitOutcome: "timeout",

416+

} as never;

417+

const recoverLaunchAgent = vi.fn(async () => ({

418+

attempted: true as const,

419+

recovered: true as const,

420+

message: "Gateway LaunchAgent was installed but not loaded; re-bootstrapped launchd service.",

421+

}));

422+

const waitForHealthy = vi.fn(async () => stillUnhealthy);

423+424+

await expect(

425+

recoverLaunchAgentAndRecheckGatewayHealth({

426+

health: unhealthy,

427+

service,

428+

port: 18790,

429+

expectedVersion: "2026.5.3",

430+

deps: { recoverLaunchAgent, waitForHealthy },

431+

}),

432+

).resolves.toMatchObject({

433+

health: { healthy: false, waitOutcome: "timeout" },

434+

launchAgentRecovery: { attempted: true, recovered: true },

435+

});

436+

});

437+

});