diff --git a/src/lib/job-search/http.test.ts b/src/lib/job-search/http.test.ts index 5c78b012..3d12929f 100644 --- a/src/lib/job-search/http.test.ts +++ b/src/lib/job-search/http.test.ts @@ -50,6 +50,13 @@ describe("requestJson", () => { await expect(requestJson("JSEARCH", url)).rejects.toMatchObject({ problem: "changed" }); }); + it("gives a source 30 seconds, as JSearch can take over 10 on a search it hasn't seen", async () => { + const timeout = vi.spyOn(AbortSignal, "timeout"); + stubFetch(() => Response.json({ ok: true })); + await requestJson("JSEARCH", url); + expect(timeout).toHaveBeenCalledWith(30_000); + }); + it("says it timed out when the source takes too long", async () => { vi.spyOn(AbortSignal, "timeout").mockReturnValue(AbortSignal.abort()); stubFetch((_, signal) => Promise.reject(signal?.reason ?? new Error("aborted"))); diff --git a/src/lib/job-search/http.ts b/src/lib/job-search/http.ts index d57516a5..98d89ef8 100644 --- a/src/lib/job-search/http.ts +++ b/src/lib/job-search/http.ts @@ -7,7 +7,9 @@ import type { JobSource } from "./search"; // fetching a posting (src/lib/posting-fetch.ts) there's no address to guard; // requests are still limited in time and size. -export const REQUEST_TIMEOUT_MS = 10_000; +// JSearch can take over 10 seconds on a search it hasn't run before; the +// agent searches once a day, so a timeout there costs the whole run. +export const REQUEST_TIMEOUT_MS = 30_000; const MAX_BYTES = 5 * 1024 * 1024; /** GETs JSON from a source, turning every failure into a JobSearchError. */