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

推荐订阅源

aimingoo的专栏
aimingoo的专栏
The Last Watchdog
The Last Watchdog
Project Zero
Project Zero
T
Threatpost
T
The Blog of Author Tim Ferriss
云风的 BLOG
云风的 BLOG
N
Netflix TechBlog - Medium
B
Blog
The GitHub Blog
The GitHub Blog
F
Full Disclosure
MyScale Blog
MyScale Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Y
Y Combinator Blog
GbyAI
GbyAI
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
NISL@THU
NISL@THU
爱范儿
爱范儿
Spread Privacy
Spread Privacy
F
Fortinet All Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园 - 叶小钗
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Hacker News - Newest:
Hacker News - Newest: "LLM"
Simon Willison's Weblog
Simon Willison's Weblog
S
Security @ Cisco Blogs
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
PCI Perspectives
PCI Perspectives
V
V2EX
人人都是产品经理
人人都是产品经理
W
WeLiveSecurity
IT之家
IT之家
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
博客园_首页
Forbes - Security
Forbes - Security
Cloudbric
Cloudbric
有赞技术团队
有赞技术团队
Application and Cybersecurity Blog
Application and Cybersecurity Blog
B
Blog RSS Feed
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Palo Alto Networks Blog
The Register - Security
The Register - Security
Google DeepMind News
Google DeepMind News
Hacker News: Ask HN
Hacker News: Ask HN
腾讯CDC
T
Threat Research - Cisco Blogs
Cyberwarzone
Cyberwarzone

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 test: trim doctor command hotspots · openclaw/openclaw@c66f16a test: isolate agent auth and spawn hotspots · openclaw/openclaw@9285935 test: stabilize MCP startup disposal race · openclaw/openclaw@dd9d2eb test: merge browser contract server suites · openclaw/openclaw@5817a76 test: narrow ollama provider discovery setup · openclaw/openclaw@a0d9598 build: declare qa-lab aimock runtime dependency · openclaw/openclaw@24431e5 test: speed up safe-bins exec harness · openclaw/openclaw@ee856ab test: preserve tool helpers in embedded runner mocks · openclaw/openclaw@acd86a0 refactor: move memory embeddings into provider plugins · openclaw/openclaw@77e6e4c test: reuse system-run temp fixtures · openclaw/openclaw@7e9ff0f test: trim hotspot wait overhead · openclaw/openclaw@12a59b0 Check: avoid duplicate boundary prep · openclaw/openclaw@baf11b8 test: reduce hotspot fixture overhead · openclaw/openclaw@3a59edd feat(ui): overhaul settings and slash command UX (#67819) thanks @Bun… · openclaw/openclaw@2cfb660 QA Matrix: exit cleanly on failure · openclaw/openclaw@42805d2 QA Matrix: isolate scenario coverage · openclaw/openclaw@7e659e1 Matrix: refresh crypto bootstrap state · openclaw/openclaw@94081d8 QA Lab: add provider registry · openclaw/openclaw@bb7e982 Matrix: add plugin changelog · openclaw/openclaw@4acab55 test: trim more hotspot overhead · openclaw/openclaw@f485311 test: trim remaining hotspot tests · openclaw/openclaw@6ba8626 test: narrow hotspot mocks · openclaw/openclaw@dbc8179 test: isolate gemini embedding request helpers · openclaw/openclaw@cd330f5 test: trim memory and mcp hotspots · openclaw/openclaw@fd48dfa test: slim provider registry mocks · openclaw/openclaw@2e08c77 test: harden Parallels update smoke · openclaw/openclaw@1a98090 feat: default Anthropic to Opus 4.7 · openclaw/openclaw@628b454 fix: harden node-host shell payload mutability checks · openclaw/openclaw@75c551e fix: land node-host approval binding for native binaries (#66731) (th… · openclaw/openclaw@29919bb CI: add daily schedule to CodeQL workflow (#67645) · openclaw/openclaw@69d25f5 fix(gateway): capture config hash after plugin auto-enable to prevent… · openclaw/openclaw@8c11210 fix: repair sanitized replay tool results before send (#67620) (thank… · openclaw/openclaw@c3c7a99 fix: restrict HTML timeout short-circuit to transient statuses · openclaw/openclaw@de129a6 fix: keep TUI watchdog bound to active run (#67401) (thanks @xantorres) · openclaw/openclaw@3525273 Gateway/skills: dedupe skills prefix-match + drop dead fallback on log · openclaw/openclaw@d7f489f Extensions/lmstudio: back off inference preload after consecutive fai… · openclaw/openclaw@b555214 TUI/streaming: add watchdog that resets the activity indicator after … · openclaw/openclaw@f44ab20 Agents/tool-loop: enable unknown-tool stream guard by default · openclaw/openclaw@36ed367 Gateway/skills: invalidate session skills snapshot on config write · openclaw/openclaw@b23d59a fix: classify HTML provider error pages correctly (#67642) (thanks @s… · openclaw/openclaw@e588e90 fix(skills): remove unused model-usage import (#67641) · openclaw/openclaw@55f05df docs(changelog): credit codex fix superseded PRs · openclaw/openclaw@e485f24 fix(openai-codex): normalize stale transport metadata in resolution a… · openclaw/openclaw@90801ba CI: pin Docker-related GitHub Actions (#67632) · openclaw/openclaw@f697b01 Android: modernize WebView and discovery API usage (#67627) · openclaw/openclaw@44a6e50 fix(deps): bump hono to 4.12.14 and @hono/node-server to 1.19.14 (GHS… · openclaw/openclaw@fbccc18 fix(deps): bump dompurify to 3.4.0 (#67614) · openclaw/openclaw@2c2dc00 CI: add explicit permissions to all workflow jobs (fixes code-scannin… · openclaw/openclaw@01b7516 fix: register bundled TTS providers and route overrides correctly (#6… · openclaw/openclaw@6ea3cdd fix: align host tilde paths with OS home (#62804) (thanks @stainlu) · openclaw/openclaw@ecfaf64 fix: flush creds queue before reconnect socket open (#67464) (thanks … · openclaw/openclaw@405c63f fix: strip standalone <function> tool call tags from visible text (#6… · openclaw/openclaw@78df859 fix(agents): preserve cli session metadata before transcript persist … · openclaw/openclaw@898fd04 docs(changelog): move cli transcript entry · openclaw/openclaw@c1817c6 fix(agents): normalize cli transcript api field · openclaw/openclaw@3a3fae0 docs(changelog): note cli transcript persistence · openclaw/openclaw@6c343f1 fix(agents): persist cli transcript turns · openclaw/openclaw@b8ef507 fix(msteams): harden security-sensitive flows (#65841) · openclaw/openclaw@c56b56e [Dashboard] Fix exec approval modal overflow for long command content… · openclaw/openclaw@053c5b0 Docs: remove QA changelog entry · openclaw/openclaw@7fd5771 QA: fix private runtime source loading (#67428) · openclaw/openclaw@d5933af docs(gateway): correct protocol.md schema path, hello-ok example, aut… · openclaw/openclaw@489404d CI: pin Node 22 runners to 22.18.0 · openclaw/openclaw@4ffa621 models.authStatus: normalize provider ids + tighten env-backed escape… · openclaw/openclaw@f2fdb9d Update CHANGELOG.md · openclaw/openclaw@7694a92 test(parallels): clean up npm update guard jobs · openclaw/openclaw@045ea7b Plugins: prefer scanDir override paths · openclaw/openclaw@b2974da fix(dreaming): default storage.mode to "separate" so phase blocks sto… · openclaw/openclaw@8c392f0 fix(memory-core): skip dreaming transcript ingestion via session stor… · openclaw/openclaw@a1b01f0 fix: dedupe replayed exec.finished node events (#67281) · openclaw/openclaw@5dcf526
fix(gateway): harden macOS update restart lifecycle · openclaw/openclaw@fa79e97
BunsDev · 2026-05-09 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -166,6 +166,7 @@ Docs: https://docs.openclaw.ai

166166

- Control UI: refresh the model cache after `session_status(model=...)` changes a session model. Fixes #79613.

167167

- Agents/context-engine: share loop-hook checkpoints with the after-turn finalizer so messages are not replayed. Fixes #79630.

168168

- Codex app-server: keep native hook relays alive for long-running turns so shell and file approvals stay reachable until the configured run window finishes. (#77533) Thanks @rubencu.

169+

- Gateway/macOS: clear ignored SIGUSR1 restart state, skip redundant package-update restarts when the refreshed LaunchAgent already serves the expected version, and give launchd a 10s throttle plus 20s shutdown window so update restarts do not leave old gateways alive or fight supervisor recovery. Fixes #79577; refs #78699 and #60885. Thanks @BunsDev.

169170

- Gateway/agent: pass the session-key agent id into inline image attachment validation so the first image in a fresh per-agent session uses the agent's vision-capable model override instead of the text-only system default. Fixes #79407. Thanks @pandadev66.

170171

- Gateway/maintenance: prune dedupe overflow against a stable excess count and keep active agent retries from starting duplicate runs after cache eviction. (#73841) Thanks @thesomewhatyou.

171172

- Control UI/subagents: suppress internal `subagent_announce` handoff prompts from requester transcripts and hide legacy inter-session wrapper rows so completed subagent results no longer surface runtime context in WebChat history. (#79618) Thanks @joshavant.

Original file line numberDiff line numberDiff line change

@@ -560,7 +560,7 @@ describe("runGatewayLoop", () => {

560560

});

561561

});

562562
563-

it("routes external SIGUSR1 through the restart scheduler before draining", async () => {

563+

it("clears stale restart state before routing external SIGUSR1 through the scheduler", async () => {

564564

vi.clearAllMocks();

565565

consumeGatewaySigusr1RestartAuthorization.mockReturnValueOnce(false);

566566

isGatewaySigusr1RestartExternallyAllowed.mockReturnValueOnce(true);

@@ -576,11 +576,37 @@ describe("runGatewayLoop", () => {

576576

delayMs: 0,

577577

reason: "SIGUSR1",

578578

});

579+

expect(markGatewaySigusr1RestartHandled).toHaveBeenCalledTimes(1);

580+

expect(markGatewaySigusr1RestartHandled.mock.invocationCallOrder[0]).toBeLessThan(

581+

scheduleGatewaySigusr1Restart.mock.invocationCallOrder[0] ?? 0,

582+

);

579583

expect(close).not.toHaveBeenCalled();

580584

expect(start).toHaveBeenCalledTimes(1);

581-

expect(markGatewaySigusr1RestartHandled).not.toHaveBeenCalled();

582585

});

583586

});

587+
588+

it("clears the in-flight restart token when an unauthorized SIGUSR1 is ignored", async () => {

589+

vi.clearAllMocks();

590+

consumeGatewaySigusr1RestartAuthorization.mockReturnValueOnce(false);

591+

isGatewaySigusr1RestartExternallyAllowed.mockReturnValueOnce(false);

592+
593+

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

594+

const { close, start } = await createSignaledLoopHarness();

595+

const sigusr1 = captureSignal("SIGUSR1");

596+
597+

sigusr1();

598+

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

599+
600+

expect(markGatewaySigusr1RestartHandled).toHaveBeenCalledTimes(1);

601+

expect(scheduleGatewaySigusr1Restart).not.toHaveBeenCalled();

602+

expect(close).not.toHaveBeenCalled();

603+

expect(start).toHaveBeenCalledTimes(1);

604+

expect(gatewayLog.warn).toHaveBeenCalledWith(

605+

"SIGUSR1 restart ignored (not authorized; commands.restart=false or use gateway tool).",

606+

);

607+

});

608+

});

609+
584610

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

585611

vi.clearAllMocks();

586612

peekGatewaySigusr1RestartReason.mockReturnValue(undefined);

Original file line numberDiff line numberDiff line change

@@ -487,6 +487,7 @@ export async function runGatewayLoop(params: {

487487

}

488488

const authorized = consumeGatewaySigusr1RestartAuthorization();

489489

if (!authorized) {

490+

markGatewaySigusr1RestartHandled();

490491

if (!isGatewaySigusr1RestartExternallyAllowed()) {

491492

gatewayLog.warn(

492493

"SIGUSR1 restart ignored (not authorized; commands.restart=false or use gateway tool).",

Original file line numberDiff line numberDiff line change

@@ -3049,6 +3049,52 @@ describe("update-cli", () => {

30493049

expect(doctorCommand).not.toHaveBeenCalled();

30503050

});

30513051
3052+

it("skips the post-refresh restart script when LaunchAgent already serves the expected package version", async () => {

3053+

const updatedRoot = createCaseDir("openclaw-updated-root");

3054+

const updatedEntrypoint = path.join(updatedRoot, "dist", "entry.js");

3055+

setupUpdatedRootRefresh({

3056+

entrypoints: [updatedEntrypoint],

3057+

gatewayUpdateImpl: async () =>

3058+

makeOkUpdateResult({

3059+

mode: "npm",

3060+

root: updatedRoot,

3061+

before: { version: "2026.4.23" },

3062+

after: { version: "2026.4.24" },

3063+

}),

3064+

});

3065+

serviceLoaded.mockResolvedValue(true);

3066+

probeGateway.mockResolvedValue({

3067+

ok: true,

3068+

close: null,

3069+

server: {

3070+

version: "2026.4.24",

3071+

connId: "updated-gateway",

3072+

},

3073+

auth: { role: "operator", scopes: ["operator.read"], capability: "read_only" },

3074+

health: null,

3075+

status: null,

3076+

presence: null,

3077+

configSnapshot: null,

3078+

connectLatencyMs: 1,

3079+

error: null,

3080+

url: "ws://127.0.0.1:18789",

3081+

});

3082+
3083+

await updateCommand({ yes: true });

3084+
3085+

expect(runCommandWithTimeout).toHaveBeenCalledWith(

3086+

[expect.stringMatching(/node/), updatedEntrypoint, "gateway", "install", "--force"],

3087+

expect.objectContaining({ cwd: updatedRoot, timeoutMs: 60_000 }),

3088+

);

3089+

expect(runCommandWithTimeout).not.toHaveBeenCalledWith(

3090+

[expect.stringMatching(/node/), updatedEntrypoint, "gateway", "restart"],

3091+

expect.anything(),

3092+

);

3093+

expect(runRestartScript).not.toHaveBeenCalled();

3094+

expect(probeGateway).toHaveBeenCalledWith(expect.objectContaining({ includeDetails: true }));

3095+

expect(defaultRuntime.exit).not.toHaveBeenCalledWith(1);

3096+

});

3097+
30523098

it("fails a package update when the restarted gateway reports activated plugin load errors", async () => {

30533099

const updatedRoot = createCaseDir("openclaw-updated-root");

30543100

const updatedEntrypoint = path.join(updatedRoot, "dist", "entry.js");

Original file line numberDiff line numberDiff line change

@@ -112,6 +112,8 @@ import { suppressDeprecations } from "./suppress-deprecations.js";

112112
113113

const CLI_NAME = resolveCliName();

114114

const SERVICE_REFRESH_TIMEOUT_MS = 60_000;

115+

const POST_REFRESH_ALREADY_HEALTHY_ATTEMPTS = 10;

116+

const POST_REFRESH_ALREADY_HEALTHY_DELAY_MS = 500;

115117

const DEFAULT_UPDATE_STEP_TIMEOUT_MS = 30 * 60_000;

116118

const POST_CORE_UPDATE_ENV = "OPENCLAW_UPDATE_POST_CORE";

117119

const POST_CORE_UPDATE_CHANNEL_ENV = "OPENCLAW_UPDATE_POST_CORE_CHANNEL";

@@ -1516,6 +1518,7 @@ async function maybeRestartService(params: {

15161518

const isPackageUpdate = isPackageManagerUpdateMode(params.result.mode);

15171519

let restarted = false;

15181520

let restartInitiated = false;

1521+

let refreshedGatewayAlreadyHealthy = false;

15191522

if (params.refreshServiceEnv) {

15201523

try {

15211524

await refreshGatewayServiceEnv({

@@ -1538,25 +1541,51 @@ async function maybeRestartService(params: {

15381541

return false;

15391542

}

15401543

}

1544+

if (isPackageUpdate && expectedGatewayVersion) {

1545+

const health = await waitForGatewayHealthyRestart({

1546+

service: resolveGatewayService(),

1547+

port: params.gatewayPort,

1548+

expectedVersion: expectedGatewayVersion,

1549+

env: params.serviceEnv,

1550+

attempts: POST_REFRESH_ALREADY_HEALTHY_ATTEMPTS,

1551+

delayMs: POST_REFRESH_ALREADY_HEALTHY_DELAY_MS,

1552+

});

1553+

refreshedGatewayAlreadyHealthy = health.healthy;

1554+

if (refreshedGatewayAlreadyHealthy && !params.opts.json) {

1555+

defaultRuntime.log(

1556+

theme.muted(

1557+

"Gateway already reports the updated version after service refresh; skipped redundant restart.",

1558+

),

1559+

);

1560+

}

1561+

}

15411562

}

1542-

if (params.restartScriptPath) {

1563+

// Service refresh can bootstrap a RunAtLoad LaunchAgent directly. When

1564+

// that already produced the expected gateway version, a second kickstart

1565+

// would only race the healthy supervisor-owned process.

1566+

if (!refreshedGatewayAlreadyHealthy && params.restartScriptPath) {

15431567

await runRestartScript(params.restartScriptPath);

15441568

restartInitiated = true;

1545-

} else if (params.refreshServiceEnv && isPackageUpdate) {

1569+

} else if (!refreshedGatewayAlreadyHealthy && params.refreshServiceEnv && isPackageUpdate) {

15461570

restarted = await runUpdatedInstallGatewayRestart({

15471571

result: params.result,

15481572

jsonMode: Boolean(params.opts.json),

15491573

invocationCwd: params.invocationCwd,

15501574

env: params.serviceEnv,

15511575

});

1552-

} else if (shouldUseLegacyProcessRestartAfterUpdate({ updateMode: params.result.mode })) {

1576+

} else if (

1577+

!refreshedGatewayAlreadyHealthy &&

1578+

shouldUseLegacyProcessRestartAfterUpdate({ updateMode: params.result.mode })

1579+

) {

15531580

restarted = await runDaemonRestart();

1554-

} else if (!params.opts.json) {

1581+

} else if (!refreshedGatewayAlreadyHealthy && !params.opts.json) {

15551582

defaultRuntime.log(theme.muted("No installed gateway service found; skipped restart."));

15561583

}

15571584
15581585

const shouldVerifyRestart =

1559-

restartInitiated || (restarted && expectedGatewayVersion !== undefined);

1586+

refreshedGatewayAlreadyHealthy ||

1587+

restartInitiated ||

1588+

(restarted && expectedGatewayVersion !== undefined);

15601589

if (shouldVerifyRestart) {

15611590

const restartHealthy = await verifyRestartedGateway(expectedGatewayVersion);

15621591

if (!restartHealthy) {

Original file line numberDiff line numberDiff line change

@@ -1,10 +1,11 @@

11

import fs from "node:fs/promises";

22

import type { GatewayServiceEnvironmentValueSource } from "./service-types.js";

33
4-

// launchd applies ThrottleInterval to any rapid relaunch, including

5-

// intentional gateway restarts. Keep it low so CLI restarts and forced

6-

// reinstalls do not stall for a full minute.

7-

export const LAUNCH_AGENT_THROTTLE_INTERVAL_SECONDS = 1;

4+

// launchd defaults to a 10s spawn throttle. Keep that default explicitly so

5+

// crash loops back off instead of respawning every second while still allowing

6+

// explicit kickstart restarts to take effect.

7+

export const LAUNCH_AGENT_THROTTLE_INTERVAL_SECONDS = 10;

8+

export const LAUNCH_AGENT_EXIT_TIMEOUT_SECONDS = 20;

89

// launchd stores plist integer values in decimal; 0o077 renders as 63 (owner-only files).

910

export const LAUNCH_AGENT_UMASK_DECIMAL = 0o077;

1011

@@ -178,5 +179,5 @@ export function buildLaunchAgentPlist({

178179

? `\n <key>Comment</key>\n <string>${plistEscape(comment.trim())}</string>`

179180

: "";

180181

const envXml = renderEnvDict(environment);

181-

return `<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0">\n <dict>\n <key>Label</key>\n <string>${plistEscape(label)}</string>\n ${commentXml}\n <key>RunAtLoad</key>\n <true/>\n <key>KeepAlive</key>\n <true/>\n <key>ThrottleInterval</key>\n <integer>${LAUNCH_AGENT_THROTTLE_INTERVAL_SECONDS}</integer>\n <key>Umask</key>\n <integer>${LAUNCH_AGENT_UMASK_DECIMAL}</integer>\n <key>ProgramArguments</key>\n <array>${argsXml}\n </array>\n ${workingDirXml}\n <key>StandardOutPath</key>\n <string>${plistEscape(stdoutPath)}</string>\n <key>StandardErrorPath</key>\n <string>${plistEscape(stderrPath)}</string>${envXml}\n </dict>\n</plist>\n`;

182+

return `<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0">\n <dict>\n <key>Label</key>\n <string>${plistEscape(label)}</string>\n ${commentXml}\n <key>RunAtLoad</key>\n <true/>\n <key>KeepAlive</key>\n <true/>\n <key>ExitTimeOut</key>\n <integer>${LAUNCH_AGENT_EXIT_TIMEOUT_SECONDS}</integer>\n <key>ThrottleInterval</key>\n <integer>${LAUNCH_AGENT_THROTTLE_INTERVAL_SECONDS}</integer>\n <key>Umask</key>\n <integer>${LAUNCH_AGENT_UMASK_DECIMAL}</integer>\n <key>ProgramArguments</key>\n <array>${argsXml}\n </array>\n ${workingDirXml}\n <key>StandardOutPath</key>\n <string>${plistEscape(stdoutPath)}</string>\n <key>StandardErrorPath</key>\n <string>${plistEscape(stderrPath)}</string>${envXml}\n </dict>\n</plist>\n`;

182183

}

Original file line numberDiff line numberDiff line change

@@ -1,6 +1,7 @@

11

import { PassThrough } from "node:stream";

22

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

33

import {

4+

LAUNCH_AGENT_EXIT_TIMEOUT_SECONDS,

45

LAUNCH_AGENT_THROTTLE_INTERVAL_SECONDS,

56

LAUNCH_AGENT_UMASK_DECIMAL,

67

} from "./launchd-plist.js";

@@ -562,7 +563,7 @@ describe("launchd install", () => {

562563

expect(state.dirModes.get(tmpDir)).toBe(0o700);

563564

});

564565
565-

it("writes KeepAlive=true policy with restrictive umask", async () => {

566+

it("writes KeepAlive=true policy with shutdown and throttle limits", async () => {

566567

const env = createDefaultLaunchdEnv();

567568

await installLaunchAgent({

568569

env,

@@ -575,6 +576,8 @@ describe("launchd install", () => {

575576

expect(plist).toContain("<key>KeepAlive</key>");

576577

expect(plist).toContain("<true/>");

577578

expect(plist).not.toContain("<key>SuccessfulExit</key>");

579+

expect(plist).toContain("<key>ExitTimeOut</key>");

580+

expect(plist).toContain(`<integer>${LAUNCH_AGENT_EXIT_TIMEOUT_SECONDS}</integer>`);

578581

expect(plist).toContain("<key>Umask</key>");

579582

expect(plist).toContain(`<integer>${LAUNCH_AGENT_UMASK_DECIMAL}</integer>`);

580583

expect(plist).toContain("<key>ThrottleInterval</key>");

Original file line numberDiff line numberDiff line change

@@ -63,14 +63,9 @@ describe("listenGatewayHttpServer", () => {

6363
6464

it("throws GatewayLockError after EADDRINUSE retries are exhausted", async () => {

6565

sleepMock.mockClear();

66-

const fake = createFakeHttpServer([

67-

{ kind: "error", code: "EADDRINUSE" },

68-

{ kind: "error", code: "EADDRINUSE" },

69-

{ kind: "error", code: "EADDRINUSE" },

70-

{ kind: "error", code: "EADDRINUSE" },

71-

{ kind: "error", code: "EADDRINUSE" },

72-

{ kind: "error", code: "EADDRINUSE" },

73-

]);

66+

const fake = createFakeHttpServer(

67+

Array.from({ length: 22 }, () => ({ kind: "error" as const, code: "EADDRINUSE" })),

68+

);

7469
7570

await expect(

7671

listenGatewayHttpServer({

@@ -80,7 +75,7 @@ describe("listenGatewayHttpServer", () => {

8075

}),

8176

).rejects.toBeInstanceOf(GatewayLockError);

8277
83-

expect(fake.closeCalls).toBe(4);

78+

expect(fake.closeCalls).toBe(20);

8479

});

8580
8681

it("wraps non-EADDRINUSE errors as GatewayLockError", async () => {

Original file line numberDiff line numberDiff line change

@@ -2,7 +2,7 @@ import type { Server as HttpServer } from "node:http";

22

import { GatewayLockError } from "../../infra/gateway-lock.js";

33

import { sleep } from "../../utils.js";

44
5-

const EADDRINUSE_MAX_RETRIES = 4;

5+

const EADDRINUSE_MAX_RETRIES = 20;

66

const EADDRINUSE_RETRY_INTERVAL_MS = 500;

77
88

async function closeServerQuietly(httpServer: HttpServer): Promise<void> {