From 47204a1db5df052b06cda806dae4895a72670274 Mon Sep 17 00:00:00 2001 From: Ayaan Zaidi Date: Wed, 29 Apr 2026 11:09:01 +0530 Subject: [PATCH] test(media): cover timeout request forwarding --- extensions/ollama/src/stream.test.ts | 13 ++++++++++++- src/media-understanding/image.test.ts | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/extensions/ollama/src/stream.test.ts b/extensions/ollama/src/stream.test.ts index 99ce3abeff8..63e40ae54b9 100644 --- a/extensions/ollama/src/stream.test.ts +++ b/extensions/ollama/src/stream.test.ts @@ -105,6 +105,7 @@ describe("createOllamaStreamFn thinking events", () => { async function streamOllamaEvents( chunks: Array>, + options: Parameters>[2] = {}, ): Promise> { const body = makeNdjsonBody(chunks); fetchWithSsrFGuardMock.mockResolvedValue({ @@ -116,7 +117,7 @@ describe("createOllamaStreamFn thinking events", () => { const stream = streamFn( { api: "ollama", provider: "ollama", id: "qwen3.5", contextWindow: 65536 } as never, { messages: [{ role: "user", content: "test" }] } as never, - {}, + options, ); const events: Array<{ type: string; [key: string]: unknown }> = []; @@ -224,4 +225,14 @@ describe("createOllamaStreamFn thinking events", () => { const textStart = events.find((e) => e.type === "text_start") as { contentIndex?: number }; expect(textStart?.contentIndex).toBe(0); }); + + it("uses generic stream timeout for Ollama request timeout", async () => { + await streamOllamaEvents([makeOllamaResponse({ content: "ok" })], { timeoutMs: 2500 }); + + expect(fetchWithSsrFGuardMock).toHaveBeenCalledWith( + expect.objectContaining({ + timeoutMs: 2500, + }), + ); + }); }); diff --git a/src/media-understanding/image.test.ts b/src/media-understanding/image.test.ts index ca37d6442f4..6d2e3144099 100644 --- a/src/media-understanding/image.test.ts +++ b/src/media-understanding/image.test.ts @@ -551,6 +551,7 @@ describe("describeImageWithModel", () => { await assertion; const [, , options] = completeMock.mock.calls[0] ?? []; expect(options?.signal?.aborted).toBe(true); + expect(options?.timeoutMs).toBe(25); }); it("rejects when image runtime setup exceeds the request timeout", async () => {