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

推荐订阅源

Blog — PlanetScale
Blog — PlanetScale
爱范儿
爱范儿
MongoDB | Blog
MongoDB | Blog
腾讯CDC
aimingoo的专栏
aimingoo的专栏
月光博客
月光博客
Engineering at Meta
Engineering at Meta
C
Check Point Blog
N
Netflix TechBlog - Medium
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LangChain Blog
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
WordPress大学
WordPress大学
博客园 - 司徒正美

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: require proxy lifecycle handles · openclaw/openclaw...
steipete · 2026-05-08 · via Recent Commits to openclaw:main

@@ -25,13 +25,32 @@ import {

2525

registerManagedProxyGatewayLoopbackNoProxy,

2626

startProxy,

2727

stopProxy,

28+

type ProxyHandle,

2829

} from "./proxy-lifecycle.js";

29303031

const mockForceResetGlobalDispatcher = vi.mocked(forceResetGlobalDispatcher);

3132

const mockBootstrapGlobalAgent = vi.mocked(bootstrapGlobalAgent);

3233

const mockLogInfo = vi.mocked(logInfo);

3334

const mockLogWarn = vi.mocked(logWarn);

343536+

function expectProxyHandle(handle: Awaited<ReturnType<typeof startProxy>>): ProxyHandle {

37+

expect(handle).toEqual(expect.objectContaining({ proxyUrl: expect.any(String) }));

38+

if (handle === null) {

39+

throw new Error("Expected managed proxy handle");

40+

}

41+

return handle;

42+

}

43+44+

function expectNoProxyUnregister(

45+

unregister: ReturnType<typeof registerManagedProxyGatewayLoopbackNoProxy>,

46+

): () => void {

47+

expect(unregister).toBeTypeOf("function");

48+

if (typeof unregister !== "function") {

49+

throw new Error("Expected Gateway NO_PROXY unregister callback");

50+

}

51+

return unregister;

52+

}

53+3554

describe("startProxy", () => {

3655

const savedEnv: Record<string, string | undefined> = {};

3756

const envKeysToClean = [

@@ -135,9 +154,14 @@ describe("startProxy", () => {

135154

proxyUrl: "http://127.0.0.1:3128",

136155

});

137156138-

expect(getActiveManagedProxyUrl()?.href).toBe("http://127.0.0.1:3128/");

157+

const activeProxyUrl = getActiveManagedProxyUrl();

158+

expect(activeProxyUrl).toEqual(expect.any(URL));

159+

if (activeProxyUrl === undefined) {

160+

throw new Error("Expected active managed proxy URL");

161+

}

162+

expect(activeProxyUrl.href).toBe("http://127.0.0.1:3128/");

139163140-

await stopProxy(handle);

164+

await stopProxy(expectProxyHandle(handle));

141165142166

expect(getActiveManagedProxyUrl()).toBeUndefined();

143167

});

@@ -147,7 +171,7 @@ describe("startProxy", () => {

147171148172

const handle = await startProxy({ enabled: true });

149173150-

expect(handle?.proxyUrl).toBe("http://127.0.0.1:3128");

174+

expect(expectProxyHandle(handle).proxyUrl).toBe("http://127.0.0.1:3128");

151175

expect(process.env["HTTP_PROXY"]).toBe("http://127.0.0.1:3128");

152176

});

153177

@@ -159,7 +183,7 @@ describe("startProxy", () => {

159183

proxyUrl: "http://127.0.0.1:3129",

160184

});

161185162-

expect(handle?.proxyUrl).toBe("http://127.0.0.1:3129");

186+

expect(expectProxyHandle(handle).proxyUrl).toBe("http://127.0.0.1:3129");

163187

expect(process.env["HTTP_PROXY"]).toBe("http://127.0.0.1:3129");

164188

});

165189

@@ -178,7 +202,7 @@ describe("startProxy", () => {

178202

proxyUrl: "http://127.0.0.1:3128",

179203

});

180204181-

expect(handle).not.toBeNull();

205+

expectProxyHandle(handle);

182206

expect(process.env["http_proxy"]).toBe("http://127.0.0.1:3128");

183207

expect(process.env["https_proxy"]).toBe("http://127.0.0.1:3128");

184208

expect(process.env["HTTP_PROXY"]).toBe("http://127.0.0.1:3128");

@@ -261,12 +285,12 @@ describe("startProxy", () => {

261285

proxyUrl: "http://127.0.0.1:3128",

262286

});

263287264-

expect(handle).not.toBeNull();

288+

const proxyHandle = expectProxyHandle(handle);

265289

expect(process.env["HTTP_PROXY"]).toBe("http://127.0.0.1:3128");

266290

expect(process.env["NO_PROXY"]).toBe("");

267291

mockForceResetGlobalDispatcher.mockClear();

268292269-

await stopProxy(handle);

293+

await stopProxy(proxyHandle);

270294271295

expect(process.env["HTTP_PROXY"]).toBe("http://previous.example.com:8080");

272296

expect(process.env["NO_PROXY"]).toBe("corp.example.com");

@@ -448,12 +472,12 @@ describe("startProxy", () => {

448472

});

449473

const agent = (global as Record<string, unknown>)["GLOBAL_AGENT"] as Record<string, unknown>;

450474451-

const unregister = registerManagedProxyGatewayLoopbackNoProxy("ws://127.0.0.1:18789");

452-453-

expect(unregister).toBeTypeOf("function");

475+

const unregister = expectNoProxyUnregister(

476+

registerManagedProxyGatewayLoopbackNoProxy("ws://127.0.0.1:18789"),

477+

);

454478

expect(agent["NO_PROXY"]).toBe("127.0.0.1:18789");

455479456-

unregister?.();

480+

unregister();

457481

expect(agent["NO_PROXY"]).toBeNull();

458482

await stopProxy(handle);

459483

});

@@ -465,15 +489,17 @@ describe("startProxy", () => {

465489

});

466490

const agent = (global as Record<string, unknown>)["GLOBAL_AGENT"] as Record<string, unknown>;

467491468-

const unregisterIpv6 = registerManagedProxyGatewayLoopbackNoProxy("ws://[::1]:18789");

469-

expect(unregisterIpv6).toBeTypeOf("function");

492+

const unregisterIpv6 = expectNoProxyUnregister(

493+

registerManagedProxyGatewayLoopbackNoProxy("ws://[::1]:18789"),

494+

);

470495

expect(agent["NO_PROXY"]).toBe("[::1]:18789");

471-

unregisterIpv6?.();

496+

unregisterIpv6();

472497473-

const unregisterLocalhost = registerManagedProxyGatewayLoopbackNoProxy("ws://localhost.:18789");

474-

expect(unregisterLocalhost).toBeTypeOf("function");

498+

const unregisterLocalhost = expectNoProxyUnregister(

499+

registerManagedProxyGatewayLoopbackNoProxy("ws://localhost.:18789"),

500+

);

475501

expect(agent["NO_PROXY"]).toBe("localhost.:18789");

476-

unregisterLocalhost?.();

502+

unregisterLocalhost();

477503478504

await stopProxy(handle);

479505

});

@@ -489,12 +515,12 @@ describe("startProxy", () => {

489515

});

490516

const agent = (global as Record<string, unknown>)["GLOBAL_AGENT"] as Record<string, unknown>;

491517492-

const unregister = registerManagedProxyGatewayLoopbackNoProxy("ws://127.0.0.1:3000");

493-494-

expect(unregister).toBeTypeOf("function");

518+

const unregister = expectNoProxyUnregister(

519+

registerManagedProxyGatewayLoopbackNoProxy("ws://127.0.0.1:3000"),

520+

);

495521

expect(agent["NO_PROXY"]).toBe("127.0.0.1:3000");

496522497-

unregister?.();

523+

unregister();

498524

await stopProxy(handle);

499525

});

500526

@@ -539,12 +565,12 @@ describe("startProxy", () => {

539565

const agent = (global as Record<string, unknown>)["GLOBAL_AGENT"] as Record<string, unknown>;

540566

agent["NO_PROXY"] = "corp.example.com";

541567542-

const unregister = registerManagedProxyGatewayLoopbackNoProxy("ws://127.0.0.1:18789");

543-544-

expect(unregister).toBeTypeOf("function");

568+

const unregister = expectNoProxyUnregister(

569+

registerManagedProxyGatewayLoopbackNoProxy("ws://127.0.0.1:18789"),

570+

);

545571

expect(agent["NO_PROXY"]).toBe("corp.example.com,127.0.0.1:18789");

546572547-

unregister?.();

573+

unregister();

548574

expect(agent["NO_PROXY"]).toBe("corp.example.com");

549575

await stopProxy(handle);

550576

});

@@ -556,8 +582,7 @@ describe("startProxy", () => {

556582

proxyUrl: "http://127.0.0.1:3128",

557583

});

558584559-

expect(handle).not.toBeNull();

560-

handle?.kill("SIGTERM");

585+

expectProxyHandle(handle).kill("SIGTERM");

561586562587

expect(process.env["HTTP_PROXY"]).toBeUndefined();

563588

expect(process.env["NO_PROXY"]).toBe("corp.example.com");