diff --git a/src/ollama.test.ts b/src/ollama.test.ts index b111055..e0beba6 100644 --- a/src/ollama.test.ts +++ b/src/ollama.test.ts @@ -62,3 +62,20 @@ it("propagates an error when Ollama is unreachable", async () => { globalThis.fetch = originalFetch; } }); + +it("propagates an error when an Ollama request times out", async () => { + const originalFetch = globalThis.fetch; + + globalThis.fetch = async (_input, init) => { + assert.ok(init?.signal); + throw new DOMException("The operation was aborted", "AbortError"); + }; + + try { + await assert.rejects(generateResponse("Explain a REST API."), { + name: "AbortError", + }); + } finally { + globalThis.fetch = originalFetch; + } +});