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

推荐订阅源

美团技术团队
人人都是产品经理
人人都是产品经理
月光博客
月光博客
V
V2EX
WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
博客园 - 三生石上(FineUI控件)
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
V
Visual Studio Blog
宝玉的分享
宝玉的分享
雷峰网
雷峰网
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - Franky
博客园 - 聂微东
博客园 - 司徒正美
博客园 - 【当耐特】
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
阮一峰的网络日志
阮一峰的网络日志

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
fix(media): handle ffprobe stdin EPIPE · openclaw/opencla...
openclaw-clo · 2026-04-29 · via Recent Commits to openclaw:main

@@ -1,5 +1,64 @@

1-

import { describe, expect, it } from "vitest";

2-

import { parseFfprobeCodecAndSampleRate, parseFfprobeCsvFields } from "./ffmpeg-exec.js";

1+

import type { ChildProcess, ExecFileOptions } from "node:child_process";

2+

import { EventEmitter } from "node:events";

3+

import { PassThrough } from "node:stream";

4+

import { beforeEach, describe, expect, it, vi } from "vitest";

5+

import {

6+

parseFfprobeCodecAndSampleRate,

7+

parseFfprobeCsvFields,

8+

runFfprobe,

9+

} from "./ffmpeg-exec.js";

10+11+

const { execFileMock, resolveSystemBinMock } = vi.hoisted(() => ({

12+

execFileMock: vi.fn(),

13+

resolveSystemBinMock: vi.fn(),

14+

}));

15+16+

vi.mock("node:child_process", async (importOriginal) => ({

17+

...(await importOriginal<typeof import("node:child_process")>()),

18+

execFile: execFileMock,

19+

}));

20+21+

vi.mock("../infra/resolve-system-bin.js", () => ({

22+

resolveSystemBin: resolveSystemBinMock,

23+

}));

24+25+

type ExecFileCallback = (

26+

error: Error | null,

27+

stdout: string | Buffer,

28+

stderr: string | Buffer,

29+

) => void;

30+31+

function createExecFileChild(): ChildProcess {

32+

const child = new EventEmitter() as ChildProcess;

33+

child.stdin = new PassThrough() as ChildProcess["stdin"];

34+

return child;

35+

}

36+37+

function mockFfprobeExecFile(child: ChildProcess): {

38+

execCallback: () => ExecFileCallback;

39+

} {

40+

let execCallback: ExecFileCallback | undefined;

41+

execFileMock.mockImplementationOnce(

42+

(_file: string, _args: string[], _options: ExecFileOptions, callback: ExecFileCallback) => {

43+

execCallback = callback;

44+

return child;

45+

},

46+

);

47+

return {

48+

execCallback: () => {

49+

if (!execCallback) {

50+

throw new Error("execFile callback was not captured");

51+

}

52+

return execCallback;

53+

},

54+

};

55+

}

56+57+

beforeEach(() => {

58+

execFileMock.mockReset();

59+

resolveSystemBinMock.mockReset();

60+

resolveSystemBinMock.mockReturnValue("/usr/bin/ffprobe");

61+

});

362463

describe("parseFfprobeCsvFields", () => {

564

function expectParsedFfprobeCsvCase(input: string, fieldCount: number, expected: string[]) {

@@ -43,3 +102,32 @@ describe("parseFfprobeCodecAndSampleRate", () => {

43102

expectParsedCodecAndSampleRateCase(input, expected);

44103

});

45104

});

105+106+

describe("runFfprobe", () => {

107+

it("handles stdin EPIPE without overriding successful ffprobe stdout", async () => {

108+

const child = createExecFileChild();

109+

const { execCallback } = mockFfprobeExecFile(child);

110+111+

const promise = runFfprobe(["pipe:0"], { input: Buffer.alloc(1024) });

112+113+

const stdinError = Object.assign(new Error("write EPIPE"), { code: "EPIPE" });

114+

expect(() => child.stdin?.emit("error", stdinError)).not.toThrow();

115+

execCallback()(null, Buffer.from("ok"), Buffer.alloc(0));

116+117+

await expect(promise).resolves.toBe("ok");

118+

});

119+120+

it("preserves the child callback error after stdin EPIPE", async () => {

121+

const child = createExecFileChild();

122+

const { execCallback } = mockFfprobeExecFile(child);

123+124+

const promise = runFfprobe(["pipe:0"], { input: Buffer.alloc(1024) });

125+126+

const stdinError = Object.assign(new Error("write EPIPE"), { code: "EPIPE" });

127+

expect(() => child.stdin?.emit("error", stdinError)).not.toThrow();

128+

const childError = new Error("ffprobe failed");

129+

execCallback()(childError, "", "");

130+131+

await expect(promise).rejects.toBe(childError);

132+

});

133+

});