Repository navigation
Description
Symptom
Visiting https://ww2.nemar.org/dataset/on005506 (and on005507, plus the others in the original #529 cohort) hangs ~5–8 seconds, then renders with empty content. Network tab shows:
/api/dataset/on005506/readme?v=v1.0.0→ HTTP 500 after ~5s (timeout)/api/dataset/on005506/tree?v=v1.0.0→ 200 with "no manifest" fallback HTML
When the browser retries 500 responses (or when multiple cards load similar pages back-to-back), the per-IP rate limit at the CF edge starts returning 429 to subsequent requests, making the experience even worse on retry.
Root cause: these datasets have latest_version_doi: null and versions: [] on data.nemar.org/<id>/ — they were never published. The current endpoint code path tries to fetch the manifest regardless, hits a 4s timeout, returns 500.
Verified state for on005506:
$ curl -s https://api.nemar.org/datasets/on005506 | jq '.dataset | {latest_version_doi, github_repo, status}'
{ "latest_version_doi": null, "github_repo": "nemarDatasets/on005506", "status": "active" }
$ curl -s https://data.nemar.org/on005506/
{ "dataset_id": "on005506", "latest": null, "versions": [] }
$ curl -s -w "%{http_code} %{time_total}s" https://ww2.nemar.org/api/dataset/on005506/readme?v=v1.0.0
500 5.16s
Fix
In src/pages/api/dataset/[id]/readme.ts and src/pages/api/dataset/[id]/tree.ts:
- Before calling
getManifest, callgetDatasetTopLevel(id)(or whatever exposesversions: []/latest: null). If no versions exist, return a clean 200 with an "unpublished" HTML state immediately — no 5s timeout, no 500. - The unpublished HTML can say something like "This dataset has been onboarded but not yet published. Check back later or contact the dataset owner."
- Same on the main
/dataset/[id]SSR path: detect unpublished early and render the unpublished state instead of waiting for the deferred client-side fetches to error out.
Also reasonable: have these endpoints honor Cache-Control: public, max-age=300 even on the unpublished branch, so the CF cache serves the cheap response on retry instead of forcing the worker to re-evaluate.
Acceptance
-
/api/dataset/on005506/readme?v=v1.0.0returns 200 in < 500ms (no manifest fetch attempted) -
/api/dataset/on005506/tree?v=v1.0.0same -
/dataset/on005506renders an unpublished state, no spinner stuck for 5s - No more 500-driven retry storms that cascade into 429s
Notes
- This is independent of the underlying AI Mode search: the on-state ring and placeholder show before, or without, the widget #529 root-cause fix (recover the missing version rows / publish flow). This issue is purely about the website rendering a graceful state for the not-yet-published case.
- Related on the data side: a separate website issue (filed alongside this one) covers introducing a compact
summary.jsonartifact so even published datasets stop pulling 10 MB manifests for path-only views.
Activity
feat(dataset): short-circuit unpublished datasets in readme + tree en…