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

推荐订阅源

H
Help Net Security
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
Stack Overflow Blog
Stack Overflow Blog
美团技术团队
博客园_首页
T
Tailwind CSS Blog
博客园 - 三生石上(FineUI控件)
B
Blog
D
DataBreaches.Net
腾讯CDC
C
Check Point Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
U
Unit 42
月光博客
月光博客
V
V2EX
Vercel News
Vercel News
T
The Blog of Author Tim Ferriss
The Cloudflare Blog
博客园 - 叶小钗
Y
Y Combinator 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
fix(google): bound TTS success JSON response reads (#9698...
mushuiyu886 · 2026-06-27 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -20,6 +20,8 @@ const {

2020

let buildGoogleSpeechProvider: typeof import("./speech-provider.js").buildGoogleSpeechProvider;

2121

let testing: typeof import("./speech-provider.js").testing;

2222
23+

const GOOGLE_TTS_JSON_CAP_BYTES = 16 * 1024 * 1024;

24+
2325

beforeAll(async () => {

2426

({ buildGoogleSpeechProvider, testing } = await import("./speech-provider.js"));

2527

});

@@ -56,6 +58,26 @@ function installGoogleTtsRequestMock(pcm = Buffer.from([1, 0, 2, 0])) {

5658

return postJsonRequestMock;

5759

}

5860
61+

function oversizedGoogleTtsJsonResponse(onCancel: () => void): Response {

62+

const response = new Response(

63+

new ReadableStream<Uint8Array>({

64+

start(controller) {

65+

controller.enqueue(new Uint8Array(GOOGLE_TTS_JSON_CAP_BYTES + 1));

66+

},

67+

cancel() {

68+

onCancel();

69+

},

70+

}),

71+

{ headers: { "content-type": "application/json" }, status: 200 },

72+

);

73+

Object.defineProperty(response, "json", {

74+

value: async () => {

75+

throw new Error("unbounded json reader was used");

76+

},

77+

});

78+

return response;

79+

}

80+
5981

function expectRecordFields(value: unknown, expected: Record<string, unknown>) {

6082

if (!value || typeof value !== "object") {

6183

throw new Error("Expected record");

@@ -149,6 +171,39 @@ describe("Google speech provider", () => {

149171

expect(transcodeAudioBufferToOpusMock).not.toHaveBeenCalled();

150172

});

151173
174+

it("bounds oversized Gemini TTS success JSON responses and cancels the stream", async () => {

175+

let cancelCount = 0;

176+

const release = vi.fn(async () => {});

177+

postJsonRequestMock

178+

.mockResolvedValueOnce({

179+

response: oversizedGoogleTtsJsonResponse(() => {

180+

cancelCount += 1;

181+

}),

182+

release,

183+

})

184+

.mockResolvedValueOnce({

185+

response: oversizedGoogleTtsJsonResponse(() => {

186+

cancelCount += 1;

187+

}),

188+

release,

189+

});

190+

const provider = buildGoogleSpeechProvider();

191+
192+

await expect(

193+

provider.synthesize({

194+

text: "oversized tts response",

195+

cfg: {},

196+

providerConfig: {

197+

apiKey: "google-test-key",

198+

},

199+

target: "audio-file",

200+

timeoutMs: 12_000,

201+

}),

202+

).rejects.toThrow("Google TTS response: JSON response exceeds 16777216 bytes");

203+

expect(cancelCount).toBe(2);

204+

expect(release).toHaveBeenCalledTimes(2);

205+

});

206+
152207

it("transcodes Gemini PCM to Opus for voice-note targets", async () => {

153208

installGoogleTtsRequestMock(Buffer.from([5, 0, 6, 0]));

154209

transcodeAudioBufferToOpusMock.mockResolvedValueOnce(Buffer.from("google-opus"));