fix(refresh): don't call a stored copy "nothing newer", and point an entry at its feature
CI / Typecheck, test, feed (push) Successful in 15s
CI / Build site (push) Successful in 8s
CI / Container image (push) Failing after 29s

When the network failed behind the service worker, it answered from its
own store. Check for new data then said nothing newer was published when
the server was never reached. The worker now marks that copy, and a fresh
check treats it as unreachable; ordinary loads still use it offline.

The built-in tasks entry linked to a follow-up fix instead of the
feature, and the changelog spec's details now match what shipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas WintherandClaude Opus 5.5 committed 2026-10-13 14:31:04 +02:00
1 parent 1fc47e2864
commit ab3173adf0
5 files changed
+37 -8

No files matched your search

+5
View File
@@ -29,6 +29,11 @@ export async function fetchFeed(
if (!res.ok) {
throw new Error(`Feed request failed (${res.status}).`);
}
// Asked for the newest data, a copy the service worker served from its own
// store is not an answer from the server: the network failed behind it.
if (options.fresh === true && res.headers.get("x-served-from") === "sw-cache") {
throw new Error("The server could not be reached; this is the stored copy.");
}
const json: unknown = await res.json();
const version = (json as { schemaVersion?: number }).schemaVersion;
+8 -1
View File
@@ -146,7 +146,14 @@ async function feedFirst(request) {
return response;
} catch {
const cached = await cache.match(request);
if (cached !== undefined) return cached;
// Marked as the stored copy, so a reader who asked for the newest data
// ("Check for new data") is told the server was not reached rather than
// that nothing newer was published. An ordinary load ignores the mark.
if (cached !== undefined) {
const headers = new Headers(cached.headers);
headers.set("x-served-from", "sw-cache");
return new Response(cached.body, { status: cached.status, headers });
}
// No network and nothing cached: say so in the feed's own shape, so the
// client renders its error state rather than failing to parse.
return new Response(