Skip to content

fix(api): don't cache failure-fallback HTML on tree/readme partials #53

Closed

Description

@neuromechanist

Symptom

ww2.nemar.org/dataset/<id> shows "No description available" / "Manifest unavailable" on otherwise-healthy datasets (reproduced on on002778, but the bug is dataset-agnostic).

Reproduction:

curl -s 'https://ww2.nemar.org/api/dataset/on002778/tree?v=v1.0.0' | wc -c
# Cold isolate: 354 bytes ("Manifest unavailable")
curl -s 'https://ww2.nemar.org/api/dataset/on002778/tree?v=v1.0.0&_cb=1' | wc -c
# Cache-busted: 187334 bytes (full tree)

Root cause

src/pages/api/dataset/[id]/tree.ts and readme.ts set

Cache-Control: public, max-age=300, s-maxage=600, stale-while-revalidate=86400

on every 200 response, including the empty fallback branches (renderNoManifest, renderReadme(null, null, ...)).

When the upstream data.nemar.org/<id>/v<x.y.z>/manifest.json fetch transiently times out from a cold Astro SSR isolate on CF Pages (the slow path is hot for any dataset whose central manifest workflow hasn't generated summary.json), the resulting empty-fallback HTML gets pinned at the CF edge for s-maxage=600 (fresh) + stale-while-revalidate=86400 (stale). Subsequent visitors keep seeing the broken state until the cache rotates.

A single cold-start failure can blank a dataset page for many hours.

Fix

On the empty/failure-fallback branches, send Cache-Control: no-store (or short max-age, no SWR) so a transient failure can't poison the edge. Keep the long s-maxage only on the success branch where the response is deterministic for the (id, version) pair.

Affected paths:

  • tree.ts line ~88: renderNoManifest(version) branch
  • readme.ts line ~124: renderReadme(source=null, ...) branch (empty source)

Related

Activity

  1. added
    bug
    on May 23, 2026
  2. added a commit that references this issue on May 23, 2026
    17575b6
  3. added a commit that references this issue on May 26, 2026
    e53e982
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions