@@ -277,19 +277,37 @@ describe("streamWithIdleTimeout", () => {
|
277 | 277 | const baseFn = vi.fn().mockReturnValue(mockStream); |
278 | 278 | const wrapped = streamWithIdleTimeout(baseFn, 1000); |
279 | 279 | |
280 | | -const model = { api: "openai" } as Parameters<typeof baseFn>[0]; |
| 280 | +const model = { api: "openai", requestTimeoutMs: 5000 } as Parameters<typeof baseFn>[0]; |
281 | 281 | const context = {} as Parameters<typeof baseFn>[1]; |
282 | 282 | const options = {} as Parameters<typeof baseFn>[2]; |
283 | 283 | |
284 | 284 | void wrapped(model, context, options); |
285 | 285 | |
286 | 286 | expect(baseFn).toHaveBeenCalledWith( |
287 | | -model, |
| 287 | +expect.objectContaining({ api: "openai", requestTimeoutMs: 1000 }), |
288 | 288 | context, |
289 | 289 | expect.objectContaining({ signal: expect.any(AbortSignal) }), |
290 | 290 | ); |
291 | 291 | }); |
292 | 292 | |
| 293 | +it("keeps model request timeouts that are shorter than the idle watchdog", () => { |
| 294 | +const mockStream = createMockAsyncIterable([]); |
| 295 | +const baseFn = vi.fn().mockReturnValue(mockStream); |
| 296 | +const wrapped = streamWithIdleTimeout(baseFn, 1000); |
| 297 | + |
| 298 | +const model = { requestTimeoutMs: 250 } as Parameters<typeof baseFn>[0]; |
| 299 | +const context = {} as Parameters<typeof baseFn>[1]; |
| 300 | +const options = {} as Parameters<typeof baseFn>[2]; |
| 301 | + |
| 302 | +void wrapped(model, context, options); |
| 303 | + |
| 304 | +expect(baseFn).toHaveBeenCalledWith( |
| 305 | +expect.objectContaining({ requestTimeoutMs: 250 }), |
| 306 | +context, |
| 307 | +expect.any(Object), |
| 308 | +); |
| 309 | +}); |
| 310 | + |
293 | 311 | it("throws on idle timeout", async () => { |
294 | 312 | vi.useFakeTimers(); |
295 | 313 | const slowStream = createNeverYieldingStream(); |
|