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

推荐订阅源

Vercel News
Vercel News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Apple Machine Learning Research
Apple Machine Learning Research
T
Tailwind CSS Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
人人都是产品经理
人人都是产品经理
V
V2EX
量子位
Last Week in AI
Last Week in AI
Jina AI
Jina AI
博客园 - 【当耐特】
爱范儿
爱范儿
宝玉的分享
宝玉的分享
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Hugging Face - Blog
Hugging Face - Blog
博客园 - 三生石上(FineUI控件)
有赞技术团队
有赞技术团队
小众软件
小众软件
IT之家
IT之家
博客园_首页
博客园 - 聂微东
S
SegmentFault 最新的问题
阮一峰的网络日志
阮一峰的网络日志
博客园 - 叶小钗

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
perf: lighten gateway watch startup · openclaw/openclaw@7...
steipete · 2026-05-04 · via Recent Commits to openclaw:main

@@ -5,7 +5,7 @@ import fs from "node:fs";

55

import path from "node:path";

66

import process from "node:process";

77

import { pathToFileURL } from "node:url";

8-

import { isRestartRelevantRunNodePath, runNodeWatchedPaths } from "./run-node.mjs";

8+

import { isRestartRelevantRunNodePath, runNodeWatchedPaths } from "./run-node-watch-paths.mjs";

991010

const WATCH_NODE_RUNNER = "scripts/run-node.mjs";

1111

const WATCH_RESTART_SIGNAL = "SIGTERM";

@@ -255,19 +255,6 @@ const releaseWatchLock = (lockHandle) => {

255255

* }} [params]

256256

*/

257257

export async function runWatchMain(params = {}) {

258-

let createWatcher = params.createWatcher;

259-

if (!createWatcher) {

260-

try {

261-

const chokidarModule = await (params.loadChokidar ?? loadChokidar)();

262-

createWatcher = (watchPaths, options) => chokidarModule.watch(watchPaths, options);

263-

} catch (err) {

264-

if (isInvalidPackageConfigError(err)) {

265-

printFriendlyWatchStartupError(err);

266-

}

267-

throw err;

268-

}

269-

}

270-271258

const deps = {

272259

spawn: params.spawn ?? spawn,

273260

process: params.process ?? process,

@@ -278,7 +265,8 @@ export async function runWatchMain(params = {}) {

278265

sleep: params.sleep ?? sleep,

279266

signalProcess: params.signalProcess ?? ((pid, signal) => process.kill(pid, signal)),

280267

lockDisabled: params.lockDisabled === true,

281-

createWatcher,

268+

createWatcher: params.createWatcher,

269+

loadChokidar: params.loadChokidar ?? loadChokidar,

282270

watchPaths: params.watchPaths ?? runNodeWatchedPaths,

283271

};

284272

@@ -293,7 +281,7 @@ export async function runWatchMain(params = {}) {

293281

childEnv.OPENCLAW_WATCH_COMMAND = deps.args.join(" ");

294282

}

295283296-

return await new Promise((resolve) => {

284+

return await new Promise((resolve, reject) => {

297285

let settled = false;

298286

let shuttingDown = false;

299287

let restartRequested = false;

@@ -357,6 +345,38 @@ export async function runWatchMain(params = {}) {

357345

settle(1);

358346

};

359347348+

const rejectWatcherStartupError = (err) => {

349+

if (settled) {

350+

return;

351+

}

352+

settled = true;

353+

shuttingDown = true;

354+

if (watchProcess && typeof watchProcess.kill === "function") {

355+

watchProcess.kill(WATCH_RESTART_SIGNAL);

356+

}

357+

releaseWatchLock(lockHandle);

358+

watcher?.close?.().catch?.(() => {});

359+

if (onSigInt) {

360+

deps.process.off("SIGINT", onSigInt);

361+

}

362+

if (onSigTerm) {

363+

deps.process.off("SIGTERM", onSigTerm);

364+

}

365+

reject(err);

366+

};

367+368+

const resolveCreateWatcher = async () => {

369+

try {

370+

const chokidarModule = await deps.loadChokidar();

371+

return (watchPaths, options) => chokidarModule.watch(watchPaths, options);

372+

} catch (err) {

373+

if (isInvalidPackageConfigError(err)) {

374+

printFriendlyWatchStartupError(err);

375+

}

376+

throw err;

377+

}

378+

};

379+360380

const runAutoDoctorAndRestart = () => {

361381

autoDoctorAttempted = true;

362382

logWatcher(

@@ -405,8 +425,11 @@ export async function runWatchMain(params = {}) {

405425

}

406426

};

407427408-

const startWatcher = () => {

409-

watcher = deps.createWatcher(deps.watchPaths, {

428+

const attachWatcher = (createWatcher) => {

429+

if (settled) {

430+

return;

431+

}

432+

watcher = createWatcher(deps.watchPaths, {

410433

ignoreInitial: true,

411434

ignored: (watchPath, stats) =>

412435

isIgnoredWatchPath(watchPath, deps.cwd, deps.watchPaths, stats),

@@ -417,6 +440,14 @@ export async function runWatchMain(params = {}) {

417440

watcher.on("error", handleWatcherError);

418441

};

419442443+

const startWatcher = () => {

444+

if (deps.createWatcher) {

445+

attachWatcher(deps.createWatcher);

446+

return;

447+

}

448+

void resolveCreateWatcher().then(attachWatcher).catch(rejectWatcherStartupError);

449+

};

450+420451

onSigInt = () => {

421452

shuttingDown = true;

422453

if (watchProcess && typeof watchProcess.kill === "function") {