From 56cb081cacd3609f3cb06daf158c06be94374f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Fri, 17 Jul 2026 10:42:51 +0200 Subject: [PATCH] Expire cached job listings after 30 seconds The job cache never expired, so CI status stayed stale for the rest of the session. --- src/components/JobCob.svelte | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/components/JobCob.svelte b/src/components/JobCob.svelte index eac1ed085..9dc30f5d3 100644 --- a/src/components/JobCob.svelte +++ b/src/components/JobCob.svelte @@ -5,7 +5,10 @@ import { HttpdClient } from "@http-client"; - const inFlightJobs = new LRUCache>({ max: 50 }); + const inFlightJobs = new LRUCache>({ + max: 200, + ttl: 30_000, + }); function fetchJobs( baseUrl: BaseUrl, @@ -15,9 +18,19 @@ const key = `${baseUrl.scheme}://${baseUrl.hostname}:${baseUrl.port}/${rid}/${commit}`; let promise = inFlightJobs.get(key); if (!promise) { - promise = new HttpdClient(baseUrl).repo.getJobsByCommit(rid, commit); - promise.catch(() => inFlightJobs.delete(key)); - inFlightJobs.set(key, promise); + const request = new HttpdClient(baseUrl).repo.getJobsByCommit( + rid, + commit, + ); + // Only evict on failure if this exact request is still cached; after the + // entry's ttl expires a later request may have replaced it under the key. + request.catch(() => { + if (inFlightJobs.peek(key) === request) { + inFlightJobs.delete(key); + } + }); + inFlightJobs.set(key, request); + promise = request; } return promise; }