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

推荐订阅源

博客园_首页
博客园 - 三生石上(FineUI控件)
爱范儿
爱范儿
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
A
About on SuperTechFans
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
Engineering at Meta
Engineering at Meta
有赞技术团队
有赞技术团队
月光博客
月光博客
M
MIT News - Artificial intelligence
V
Visual Studio Blog
Stack Overflow Blog
Stack Overflow Blog
阮一峰的网络日志
阮一峰的网络日志
D
DataBreaches.Net
I
InfoQ
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
雷峰网
雷峰网

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
Recover stale embedded tool calls during gateway diagnost...
joshavant · 2026-05-16 · via Recent Commits to openclaw:main

@@ -10,6 +10,7 @@ import { createLazyImportLoader } from "../../shared/lazy-promise.js";

1010

const gatewayLog = createSubsystemLogger("gateway");

1111

const LAUNCHD_SUPERVISED_RESTART_EXIT_DELAY_MS = 1500;

1212

const DEFAULT_RESTART_DRAIN_TIMEOUT_MS = 300_000;

13+

const RESTART_ACTIVE_EMBEDDED_RUN_ABORT_GRACE_MS = 30_000;

1314

const RESTART_DRAIN_STILL_PENDING_WARN_MS = 30_000;

1415

const UPDATE_RESPAWN_HEALTH_TIMEOUT_MS = 10_000;

1516

const UPDATE_RESPAWN_HEALTH_POLL_MS = 200;

@@ -345,6 +346,15 @@ export async function runGatewayLoop(params: {

345346

restartDrainTimeoutMs === undefined

346347

? "without a timeout"

347348

: `with timeout ${restartDrainTimeoutMs}ms`;

349+

const resolveActiveRunDrainWaitMs = (activeRuns: number): RestartDrainTimeoutMs => {

350+

if (activeRuns <= 0) {

351+

return restartDrainTimeoutMs;

352+

}

353+

if (restartDrainTimeoutMs === undefined) {

354+

return RESTART_ACTIVE_EMBEDDED_RUN_ABORT_GRACE_MS;

355+

}

356+

return Math.min(restartDrainTimeoutMs, RESTART_ACTIVE_EMBEDDED_RUN_ABORT_GRACE_MS);

357+

};

348358

const armCloseForceExitTimerForIndefiniteRestart = () => {

349359

if (isRestart && restartDrainTimeoutMs === undefined) {

350360

armForceExitTimer(SHUTDOWN_TIMEOUT_MS);

@@ -417,22 +427,40 @@ export async function runGatewayLoop(params: {

417427

gatewayLog.warn("forced restart requested; skipping active work drain");

418428

abortEmbeddedPiRun(undefined, { mode: "all" });

419429

} else {

430+

const activeRunDrainWaitMs = resolveActiveRunDrainWaitMs(activeRuns);

420431

const stillPendingDrainLogger = createStillPendingDrainLogger();

421-

const [tasksDrain, runsDrain] = await Promise.all([

422-

activeTasks > 0

423-

? waitForActiveTasks(restartDrainTimeoutMs)

424-

: Promise.resolve({ drained: true }),

425-

activeRuns > 0

426-

? waitForActiveEmbeddedRuns(restartDrainTimeoutMs)

427-

: Promise.resolve({ drained: true }),

428-

]).finally(() => clearInterval(stillPendingDrainLogger));

432+

let abortedAfterRunGrace = false;

433+

let tasksDrain: { drained: boolean } = { drained: true };

434+

let runsDrain: { drained: boolean } = { drained: true };

435+

try {

436+

const tasksDrainPromise =

437+

activeTasks > 0

438+

? waitForActiveTasks(restartDrainTimeoutMs)

439+

: Promise.resolve({ drained: true });

440+

runsDrain =

441+

activeRuns > 0

442+

? await waitForActiveEmbeddedRuns(activeRunDrainWaitMs)

443+

: { drained: true };

444+

if (!runsDrain.drained && activeRuns > 0) {

445+

gatewayLog.warn(

446+

"active embedded run drain grace reached; aborting active run(s) before restart",

447+

);

448+

abortEmbeddedPiRun(undefined, { mode: "all" });

449+

abortedAfterRunGrace = true;

450+

}

451+

tasksDrain = await tasksDrainPromise;

452+

} finally {

453+

clearInterval(stillPendingDrainLogger);

454+

}

429455

if (tasksDrain.drained && runsDrain.drained) {

430456

gatewayLog.info("all active work drained");

431457

} else {

432458

gatewayLog.warn("drain timeout reached; proceeding with restart");

433459

// Final best-effort abort to avoid carrying active runs into the

434460

// next lifecycle when drain time budget is exhausted.

435-

abortEmbeddedPiRun(undefined, { mode: "all" });

461+

if (!abortedAfterRunGrace) {

462+

abortEmbeddedPiRun(undefined, { mode: "all" });

463+

}

436464

}

437465

}

438466

}