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

推荐订阅源

V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
月光博客
月光博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
博客园 - Franky
The GitHub Blog
The GitHub Blog
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
B
Blog RSS Feed
云风的 BLOG
云风的 BLOG
小众软件
小众软件
罗磊的独立博客
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
美团技术团队
H
Hackread – Cybersecurity News, Data Breaches, AI and More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
C
Check Point Blog
WordPress大学
WordPress大学
博客园 - 【当耐特】
博客园 - 司徒正美
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
refactor: dedupe approval and benchmark helpers · opencla...
vincentkoc · 2026-05-29 · via Recent Commits to openclaw:main

@@ -1,4 +1,4 @@

1-

import { spawn, spawnSync, type ChildProcessWithoutNullStreams } from "node:child_process";

1+

import { spawn, spawnSync } from "node:child_process";

22

import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";

33

import { request } from "node:http";

44

import { createServer } from "node:net";

@@ -7,6 +7,7 @@ import path from "node:path";

77

import { performance } from "node:perf_hooks";

88

import { pathToFileURL } from "node:url";

99

import { parseStrictIntegerOption } from "./lib/dev-tooling-safety.ts";

10+

import { delay, stopChild } from "./lib/gateway-bench-child.ts";

10111112

type GatewayBenchCase = {

1213

config: Record<string, unknown>;

@@ -80,15 +81,6 @@ type BenchmarkFailure = {

8081

sampleIndex: number;

8182

};

828383-

type ChildExit = {

84-

exitCode: number | null;

85-

signal: string | null;

86-

};

87-88-

type StopChildResult = ChildExit & {

89-

exitedBeforeTeardown: boolean;

90-

};

91-9284

type PluginFixtureResult = {

9385

pluginIds: string[];

9486

pluginsDir: string;

@@ -109,8 +101,6 @@ const DEFAULT_RUNS = 5;

109101

const DEFAULT_WARMUP = 1;

110102

const DEFAULT_TIMEOUT_MS = 30_000;

111103

const DEFAULT_ENTRY = "dist/entry.js";

112-

const TEARDOWN_GRACE_MS = 2_000;

113-

const TEARDOWN_KILL_GRACE_MS = 1_000;

114104115105

const BASE_CONFIG = {

116106

browser: { enabled: false },

@@ -624,10 +614,6 @@ function requestStatus(port: number, pathname: string): Promise<number> {

624614

});

625615

}

626616627-

function delay(ms: number): Promise<void> {

628-

return new Promise((resolve) => setTimeout(resolve, ms));

629-

}

630-631617

function writePluginFixtures(

632618

root: string,

633619

count: number,

@@ -710,83 +696,6 @@ function sanitizedEnv(

710696

return env;

711697

}

712698713-

async function stopChild(

714-

child: ChildProcessWithoutNullStreams,

715-

options: { killGraceMs?: number; teardownGraceMs?: number } = {},

716-

): Promise<StopChildResult> {

717-

const currentExit = (): ChildExit | null =>

718-

child.exitCode != null || child.signalCode != null

719-

? { exitCode: child.exitCode, signal: child.signalCode }

720-

: null;

721-722-

const existingExit = currentExit();

723-

if (existingExit != null) {

724-

return { ...existingExit, exitedBeforeTeardown: true };

725-

}

726-727-

let observedExit: ChildExit | null = null;

728-

const exited = new Promise<ChildExit>((resolve) => {

729-

child.once("exit", (exitCode, signal) => {

730-

observedExit = { exitCode, signal };

731-

resolve(observedExit);

732-

});

733-

});

734-

const waitForExit = async (ms: number): Promise<ChildExit | null> =>

735-

await Promise.race([exited, delay(ms).then(() => null)]);

736-737-

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

738-

const queuedExit = observedExit ?? currentExit();

739-

if (queuedExit != null) {

740-

return { ...queuedExit, exitedBeforeTeardown: true };

741-

}

742-743-

const teardownGraceMs = options.teardownGraceMs ?? TEARDOWN_GRACE_MS;

744-

const killGraceMs = options.killGraceMs ?? TEARDOWN_KILL_GRACE_MS;

745-

const sentTeardownSignal = killProcessTree(child, "SIGTERM");

746-

const gracefulExit = await waitForExit(teardownGraceMs);

747-

if (gracefulExit != null) {

748-

return { ...gracefulExit, exitedBeforeTeardown: !sentTeardownSignal };

749-

}

750-751-

const postGraceExit = currentExit() ?? observedExit;

752-

if (postGraceExit != null) {

753-

return { ...postGraceExit, exitedBeforeTeardown: !sentTeardownSignal };

754-

}

755-

if (!sentTeardownSignal) {

756-

releaseUnsettledChild(child);

757-

return { exitCode: null, exitedBeforeTeardown: true, signal: null };

758-

}

759-760-

killProcessTree(child, "SIGKILL");

761-

const killedExit = await waitForExit(killGraceMs);

762-

const finalExit = killedExit ?? currentExit() ?? observedExit;

763-

if (finalExit != null) {

764-

return { ...finalExit, exitedBeforeTeardown: false };

765-

}

766-767-

releaseUnsettledChild(child);

768-

return { exitCode: null, exitedBeforeTeardown: false, signal: "SIGKILL" };

769-

}

770-771-

function releaseUnsettledChild(child: ChildProcessWithoutNullStreams): void {

772-

child.stdin.destroy();

773-

child.stdout.destroy();

774-

child.stderr.destroy();

775-

child.unref();

776-

}

777-778-

function killProcessTree(child: ChildProcessWithoutNullStreams, signal: NodeJS.Signals): boolean {

779-

if (process.platform !== "win32" && child.pid !== undefined) {

780-

try {

781-

process.kill(-child.pid, signal);

782-

return true;

783-

} catch {

784-

// Fall back to the direct child below.

785-

}

786-

}

787-

return child.kill(signal);

788-

}

789-790699

function collectStartupTrace(line: string, startupTrace: Record<string, number>): void {

791700

const phaseMatch = /startup trace: ([^ ]+) ([0-9.]+)ms total=([0-9.]+)ms(?: (.*))?/u.exec(line);

792701

if (phaseMatch) {