From 536907874e109f2b34c1562bf6290003c95f6e94 Mon Sep 17 00:00:00 2001 From: Berkay Turk Date: Tue, 27 Oct 2026 20:48:22 +0100 Subject: [PATCH] fix: give job sources 30 seconds instead of 10 JSearch often takes more than 10 seconds to answer a search it hasn't run before. In a fresh instance, the first try of both a Geneva search and a remote France search timed out with "JSearch isn't answering right now", and the second try of each worked. On Find jobs this costs one extra click. For the job agent it costs the whole day: it searches once per run, and a JobSearchError ends the run. That leaves at most three runs in 24 hours to retry by hand. Co-Authored-By: Claude Opus 5.5 --- src/lib/job-search/http.test.ts | 7 +++++++ src/lib/job-search/http.ts | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) 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. */