Skip to content

#74: Tree totals from summary.totals.bytes + 4s summary timeout on partials - #75

Merged
neuromechanist merged 1 commit into
mainfrom
feature/issue-74-hotfix-tree-totals
May 27, 2026
Merged

neuromechanist merged 1 commit into
mainfrom
feature/issue-74-hotfix-tree-totals

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

Two user-visible regressions on https://ww2.nemar.org/dataset/<id> for HBN-sized datasets. Both touch tree.ts, both are small, both land here together.

1. Panel header read "0 B total" for every dataset

render-tree.ts displays root.totalSize for the header line ("N top-level entries · X B total"). On the schema 1.1 summary fast path, buildTreeFromPaths synthesizes zero-size manifest entries (intentional — summary.json deliberately drops per-entry sizes to keep the payload small), so root.totalSize propagated as 0. Meanwhile summary.totals.bytes was already populated and accurate (e.g., on005512 reports 168778508210 for 168 GB).

Fix: add an optional rootTotalSize parameter to buildTreeFromPaths, pass summary.totals?.bytes from tree.ts. Per-file "0 B" rows are NOT in scope — they need schema 1.2 (filed as nemar-cli#635 + #73).

2. Cold-isolate first-visit timeouts on the partial endpoints

readme.ts and tree.ts both fetched summary.json with timeoutMs: 1_500. HBN-sized summary.json is 400-750 KB; on a cold CF isolate the 1.5s ceiling was triggering the manifest / no-manifest fallback chain on first visit, surfacing as "Manifest unavailable" and "No description available" placeholders. User report 2026-05-27 confirmed it across on005510 / on005511 / on005512: 2-3 refresh cycles before things load, after which data.nemar.org's s-maxage=86400 keeps the entry warm for 24 h on that PoP.

Fix: bump the summary fetch to 4 s on both endpoints (matches the metadata fetch's existing default). Landing stays at 1.5 s — landing is a tiny payload, and a slow landing usually means dataset-doesn't-exist where a fast 404 is the right move.

Closes #74

Files touched

  • src/lib/bids-tree.ts — buildTreeFromPaths gains the additive rootTotalSize?: number parameter; existing callers (which pass no second argument) unaffected.
  • src/pages/api/dataset/[id]/tree.ts — summary timeout 1.5 → 4 s; call site threads summary.totals?.bytes through the new parameter.
  • src/pages/api/dataset/[id]/readme.ts — summary timeout 1.5 → 4 s (parity with tree.ts; same cold-isolate path triggers Step 0.5's failure-fallback).
  • src/lib/bids-tree.test.ts — 2 new tests for the override branch + the no-override back-compat default.

Test plan

  • bun run typecheck — 0 errors / 0 warnings / 0 hints
  • bun run lint — biome clean
  • bun run test — 403/403 (was 401; +2 in bids-tree.test.ts)
  • bun run build — astro build clean
  • Post-deploy: panel header on /dataset/on005512 reads "157 GB total" (or similar) instead of "0 B total"
  • Post-deploy: first-cold-PoP visit to a previously-unvisited HBN dataset loads README + tree on first try without the 2-3 refresh cycle

Out of scope (filed separately, intentionally)

  • Per-file size column (every row shows "0 B") — needs schema 1.2 with summary.path_sizes. Filed as nemar-cli#635 (backend) and Consume summary.path_sizes for per-file sizes in BIDS tree #73 (consumer).
  • Architectural fix where the partial endpoints read summary from the page-bundle (which is already SSR-warmed and edge-cached) instead of doing their own summary.json fetch. The proper solution; defer to its own sprint once we see whether the timeout bump alone is enough.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 27, 2026 •

Copy link
Copy Markdown

Two user-visible fixes that both touch tree.ts. Filed and motivated
in #74; per-file sizes (the other "0 B" symptom) stay out of scope
and live in #73 + nemar-cli#635 (schema 1.2 path_sizes).

- Panel header on /dataset/<id> read "X top-level entries · 0 B
  total" for every dataset because buildTreeFromPaths synthesized
  zero-size manifest entries. summary.json already carries an
  accurate summary.totals.bytes (e.g., 168_778_508_210 = ~157 GB
  on on005512); thread it through a new optional rootTotalSize
  parameter on buildTreeFromPaths so the header reports it
  correctly. Per-file rows still display 0 B (waiting on 1.2).

- /api/dataset/<id>/{readme,tree} both fetched summary.json with
  timeoutMs: 1_500. HBN-sized summary.json is 400-750 KB; on a
  cold CF isolate the 1.5s ceiling triggered the manifest /
  no-manifest fallback chain on first visit ("Manifest unavailable"
  + "No description available" on /dataset/on005510, on005511,
  on005512 cold; takes 2-3 refreshes to warm the data.nemar.org
  edge entry, after which it sticks for s-maxage=86400). Bump
  summary fetch to 4s in both endpoints. Landing stays at 1.5s
  (tiny payload, slow landing usually = dataset doesn't exist).

403/403 tests pass (+2 new for the rootTotalSize override branch
and its back-compat zero-default).

Closes #74
@neuromechanist
neuromechanist force-pushed the feature/issue-74-hotfix-tree-totals branch from b01a06a to f87833e Compare May 27, 2026 13:05
@neuromechanist
neuromechanist merged commit eae55ae into main May 27, 2026
1 check passed
@neuromechanist
neuromechanist deleted the feature/issue-74-hotfix-tree-totals branch June 21, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hotfix: tree totals from summary.totals.bytes + raise summary timeout on partial endpoints

1 participant