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

推荐订阅源

Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
J
Java Code Geeks
L
LangChain Blog
V
V2EX
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
博客园 - Franky
Microsoft Azure Blog
Microsoft Azure Blog
Jina AI
Jina AI
Blog — PlanetScale
Blog — PlanetScale
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
博客园 - 司徒正美
B
Blog
G
Google Developers Blog
Stack Overflow Blog
Stack Overflow Blog
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
Engineering at Meta
Engineering at Meta
MyScale Blog
MyScale Blog
有赞技术团队
有赞技术团队
Hugging Face - Blog
Hugging Face - 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
Harden browser download output writes (#78780) · openclaw...
jesse-merhi · 2026-05-08 · via Recent Commits to openclaw:main

@@ -96,6 +96,14 @@ function effectiveSpawnCommand(call: unknown[] | undefined): unknown {

9696

return command;

9797

}

989899+

function mockExpiredLaunchPollingClock(): void {

100+

let now = 1_000_000;

101+

vi.spyOn(Date, "now").mockImplementation(() => {

102+

now += 1_000;

103+

return now;

104+

});

105+

}

106+99107

async function withMockChromeCdpServer(params: {

100108

wsPath: string;

101109

onConnection?: (wss: WebSocketServer) => void;

@@ -507,15 +515,16 @@ describe("chrome.ts internal", () => {

507515

let spawnCalls = 0;

508516

const firstProc = makeFakeProc();

509517

const secondProc = makeFakeProc();

518+

mockExpiredLaunchPollingClock();

510519

spawnMock.mockImplementation(() => {

511520

spawnCalls += 1;

512521

if (spawnCalls === 1) {

513-

setTimeout(() => {

522+

void Promise.resolve().then(() => {

514523

firstProc.stderr.emit(

515524

"data",

516525

Buffer.from("The profile appears to be in use by another Chromium process"),

517526

);

518-

}, 0);

527+

});

519528

return firstProc;

520529

}

521530

cdpReachable = true;

@@ -566,7 +575,10 @@ describe("chrome.ts internal", () => {

566575

const fakeProc = makeFakeProc();

567576

spawnMock.mockReturnValue(fakeProc);

568577

// Leak some stderr into the buffer so the hint renders.

569-

setTimeout(() => fakeProc.stderr.emit("data", Buffer.from("crash dump\n")), 10);

578+

void Promise.resolve().then(() =>

579+

fakeProc.stderr.emit("data", Buffer.from("crash dump\n")),

580+

);

581+

mockExpiredLaunchPollingClock();

570582571583

// fetch always fails → isChromeReachable returns false every poll.

572584

vi.stubGlobal("fetch", vi.fn().mockRejectedValue(new Error("ECONNREFUSED")));

@@ -587,38 +599,32 @@ describe("chrome.ts internal", () => {

587599

});

588600589601

it("uses the configured local launch timeout while waiting for CDP discovery", async () => {

590-

vi.useFakeTimers();

591-

try {

592-

const executablePath = path.join(tmpDir, "chrome");

593-

await fsp.writeFile(executablePath, "");

594-

const existsSync = fs.existsSync.bind(fs);

595-

vi.spyOn(fs, "existsSync").mockImplementation((p) => {

596-

const s = String(p);

597-

if (s.endsWith("Local State") || s.endsWith("Preferences")) {

598-

return true;

599-

}

600-

return existsSync(p);

601-

});

602-

const fakeProc = makeFakeProc();

603-

spawnMock.mockReturnValue(fakeProc);

604-

vi.stubGlobal("fetch", vi.fn().mockRejectedValue(new Error("ECONNREFUSED")));

605-606-

const resolved = {

607-

...makeResolved(),

608-

executablePath,

609-

localLaunchTimeoutMs: 1,

610-

};

611-

const profile = makeProfile(55556);

612-

const rejection = expect(launchOpenClawChrome(resolved, profile)).rejects.toThrow(

613-

/Failed to start Chrome CDP/,

614-

);

602+

const executablePath = path.join(tmpDir, "chrome");

603+

await fsp.writeFile(executablePath, "");

604+

const existsSync = fs.existsSync.bind(fs);

605+

vi.spyOn(fs, "existsSync").mockImplementation((p) => {

606+

const s = String(p);

607+

if (s.endsWith("Local State") || s.endsWith("Preferences")) {

608+

return true;

609+

}

610+

return existsSync(p);

611+

});

612+

const fakeProc = makeFakeProc();

613+

spawnMock.mockReturnValue(fakeProc);

614+

mockExpiredLaunchPollingClock();

615+

vi.stubGlobal("fetch", vi.fn().mockRejectedValue(new Error("ECONNREFUSED")));

615616616-

await vi.advanceTimersByTimeAsync(10);

617-

await rejection;

618-

expect(fakeProc.kill).toHaveBeenCalledWith("SIGKILL");

619-

} finally {

620-

vi.useRealTimers();

621-

}

617+

const resolved = {

618+

...makeResolved(),

619+

executablePath,

620+

localLaunchTimeoutMs: 1,

621+

};

622+

const profile = makeProfile(55556);

623+624+

await expect(launchOpenClawChrome(resolved, profile)).rejects.toThrow(

625+

/Failed to start Chrome CDP/,

626+

);

627+

expect(fakeProc.kill).toHaveBeenCalledWith("SIGKILL");

622628

});

623629

});

624630

@@ -997,9 +1003,12 @@ describe("chrome.ts internal", () => {

9971003

const fakeProc = makeFakeProc();

9981004

spawnMock.mockImplementation(() => {

9991005

// Synthesize stderr data shortly after spawn.

1000-

setTimeout(() => fakeProc.stderr.emit("data", Buffer.from("chrome crash log\n")), 5);

1006+

void Promise.resolve().then(() =>

1007+

fakeProc.stderr.emit("data", Buffer.from("chrome crash log\n")),

1008+

);

10011009

return fakeProc;

10021010

});

1011+

mockExpiredLaunchPollingClock();

10031012

vi.stubGlobal("fetch", vi.fn().mockRejectedValue(new Error("ECONNREFUSED")));

10041013

const profile = {

10051014

name: "openclaw-stderr",

@@ -1036,6 +1045,7 @@ describe("chrome.ts internal", () => {

10361045

return false;

10371046

});

10381047

spawnMock.mockImplementation(() => makeFakeProc());

1048+

mockExpiredLaunchPollingClock();

10391049

vi.stubGlobal("fetch", vi.fn().mockRejectedValue(new Error("ECONNREFUSED")));

10401050

const profile = {

10411051

name: "openclaw-mac",

@@ -1064,13 +1074,9 @@ describe("chrome.ts internal", () => {

1064107410651075

it("breaks out of the bootstrap prefs-wait loop as soon as both files exist", async () => {

10661076

// Covers the `if (exists(localStatePath) && exists(preferencesPath)) break;` branch.

1067-

// Use a wallclock flag that the mock checks each call so the loop

1068-

// iterates (awaiting its 100ms setTimeout) once with prefs-absent,

1069-

// then the flag flips and the next iteration hits the break.

1070-

let prefsVisible = false;

1071-

setTimeout(() => {

1072-

prefsVisible = true;

1073-

}, 50);

1077+

// The first prefs probe makes bootstrap necessary; subsequent probes

1078+

// make both prefs files visible so the polling loop breaks immediately.

1079+

let prefsProbeCount = 0;

10741080

vi.spyOn(fs, "existsSync").mockImplementation((p) => {

10751081

const s = String(p);

10761082

if (

@@ -1081,7 +1087,8 @@ describe("chrome.ts internal", () => {

10811087

return true;

10821088

}

10831089

if (s.endsWith("Local State") || s.endsWith("Preferences")) {

1084-

return prefsVisible;

1090+

prefsProbeCount += 1;

1091+

return prefsProbeCount > 1;

10851092

}

10861093

return false;

10871094

});

@@ -1136,17 +1143,15 @@ describe("chrome.ts internal", () => {

11361143

});

11371144

const bootstrapProc = makeFakeProc();

11381145

const runtimeProc = makeFakeProc();

1146+

bootstrapProc.kill = vi.fn((_sig?: string) => {

1147+

bootstrapProc.killed = true;

1148+

bootstrapProc.exitCode = 0;

1149+

return true;

1150+

});

11391151

let callCount = 0;

11401152

spawnMock.mockImplementation(() => {

11411153

callCount += 1;

1142-

if (callCount === 1) {

1143-

// Set exitCode shortly after spawn so the exit-wait loop breaks.

1144-

setTimeout(() => {

1145-

bootstrapProc.exitCode = 0;

1146-

}, 25);

1147-

return bootstrapProc;

1148-

}

1149-

return runtimeProc;

1154+

return callCount === 1 ? bootstrapProc : runtimeProc;

11501155

});

11511156

await withMockChromeCdpServer({

11521157

wsPath: "/devtools/browser/EXIT_BREAK",