Skip to content

Eliminate per-pageload GitHub roundtrip for README #63

Closed

Description

@neuromechanist

Symptom

Cold dataset detail pages on ww2.nemar.org block on a synchronous fetch to raw.githubusercontent.com/<org>/<id>/main/README.md whenever summary.json doesn't carry the README inline. From low-bandwidth connections this is the dominant first-paint latency for the description panel.

Reproduction with on005505:

  • summary.json is present (428 KB) and includes readme: { path: "README.md" } only
  • readme.ts step 1 fast path resolves the path, then fires fetchGithubReadme() for the actual content
  • On a cold Pages isolate, that GitHub round-trip is the main wall-clock cost

Root cause (design)

src/pages/api/dataset/[id]/readme.ts (current code) resolves in this order:

  1. summary fast path → reads summary.readme.path, then fetches GitHub raw for content
  2. manifest README via presigned URL
  3. GitHub raw without summary signal
  4. BIDS dataset_description

All four steps either roundtrip GitHub or download a multi-MB manifest. There is no path where the README content is served from a pre-rendered artifact on data.nemar.org. Every visitor pays the round-trip the first time the response isn't in the local edge cache.

Proposal

Stop fetching GitHub at request time. Have the website's readme partial read the README content directly from summary.json once the generator publishes it there (see companion issue on nemarOrg/nemar-cli).

Website-side change (this issue)

  1. Add readme.content (raw markdown) and optionally readme.html (server-rendered) to the consumer types in src/lib/data-api.ts.
  2. In readme.ts:
    • If summary.readme.content is present, render markdown and return immediately. No GitHub call, no manifest fetch.
    • Keep current fallbacks intact for older summary.json files (schema_version 1.0) so deployment is decoupled from backfill.
  3. Optional: if generator ships readme.html, skip markdown render entirely in the worker.

Acceptance

  • /api/dataset/<id>/readme?v=<v> returns README HTML in < 200 ms on a cold isolate when summary.json carries readme.content
  • Zero outbound fetches to raw.githubusercontent.com in the README hot path under flag-on conditions
  • Fallback to GitHub raw still works for legacy schema_version 1.0 summaries
  • CI green; design-review verifies no visible change

Related

Activity

  1. added
    enhancement
    on May 26, 2026
  2. added 2 commits that reference this issue on May 26, 2026
  3. neuromechanist commented on May 27, 2026

    @neuromechanist
    ContributorAuthor

    Backend side is live and backfilled — schema 1.1 with embedded readme.content is now present for all 130 published versions on data.nemar.org. nemarOrg/nemar-cli#616 closed.

    Quick verification:

    $ curl -s https://data.nemar.org/on005505/v1.0.0/summary.json?_cb=$(date +%s) | jq '.schema_version, (.readme | keys)'
    "1.1"
    [ "content", "content_bytes", "path", "sha256", "truncated" ]
    

    Whenever you're ready, this issue's consumer change can land. The fast path:

    // In src/pages/api/dataset/[id]/readme.ts step 1 (current code already
    // uses summary.readme.path; just add this branch before the GitHub fetch):
    if (summary?.readme?.content) {
      return new Response(renderReadme(summary.readme.content, "manifest", null), {
        status: 200,
        headers: {
          "Content-Type": "text/html; charset=utf-8",
          "Cache-Control": PUBLISHED_CACHE,
        },
      });
    }
    // existing GitHub-raw fallback remains for any version whose content
    // is null (e.g. annexed or oversize — `readme.truncated === true`)

    For consumers that want everything in one shot (also live now): nemarOrg/nemar-cli#617 shipped GET /<id>/page-bundle.json?v=<v> returning landing + metadata + summary + catalog in a single SSR fetch. Docs at docs/reference/data-api.md. Use it if you want to collapse the cold-load waterfall to 1 RTT — the bundle's summary.data.readme.content is the same field as the standalone summary's.

    Follow-ups filed and intentionally non-blocking:

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions