Repository navigation
fix(admin): probe summary.json directly from S3 (not via self-Worker) - #630
Merged
Merged
Conversation
Discovered on first post-deploy smoke of /admin/summary/coverage: all 130 published versions classified as kind: error, status: 522 (Cloudflare 'origin connection timed out'). Direct curl to the same data.nemar.org/<id>/<v>/summary.json URL from outside returned 200 in ~730ms. The 522 only happens when the call originates inside the Worker. Root cause: probeSummary used globalThis.fetch against data.nemar.org/<id>/<v>/summary.json, but that URL is served by the SAME Worker that hosts /admin/summary/coverage. Fanning out 8 concurrent × 130 ids triggers Worker-to-Worker subrequest behavior that 522s under load. Cross-component code-reviewer flagged this as 'option c' on PR #623 (the cleaner alternative to the cache-bust fix we shipped at the time); the bill came due on first prod run. Fix: refactor probeSummary to read S3 directly via loadSummary() — the same code path Phase 3's page-bundle service uses for its summary fan-in. Bypasses CF + the self-call entirely, so no subrequest limit and no 24h s-maxage to cache-bust around. Wiring: introduce SummaryFetcher type + defaultSummaryFetcher(env) builder, and dependency-inject the fetcher into probeSummary / buildCoverageReport. Tests stub the fetcher directly instead of swapping globalThis.fetch. Tests: 11 unit tests cover the schema classifier (ok / stale / forward-compat 1.2 / forward-compat 2.0 / missing / error / malformed JSON / empty schema_version / missing key / non-string schema / fetcher-args wire contract). Backend typecheck clean.
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR630Version: 🤖 Updated on each push. |
This was referenced May 27, 2026
Contributor
Author
|
3-agent review complete. Fixed inline:
Deferred follow-ups (real but not hotfix-blocking; documented for next iteration):
Tests: 14/14 pass (was 11 → +3). Backend typecheck clean. CI pending on push. |
3 of 6 tasks
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom (observed live on prod)
First post-deploy smoke of
GET /admin/summary/coveragereturned 130 versions, allkind: error, status: 522(Cloudflare "origin connection timed out"). Direct curl to the samedata.nemar.org/<id>/<v>/summary.jsonURL from outside returned 200 in ~730 ms. The 522 only fires when the call originates inside the Worker.Root cause
probeSummaryusedglobalThis.fetchagainstdata.nemar.org/<id>/<v>/summary.json. That URL is served by the same Worker that hosts/admin/summary/coverage. Fanning out 8 concurrent × 130 ids triggers Cloudflare Worker-to-Worker subrequest behavior that 522s under load.The cross-component code-reviewer flagged this back on PR #623 as "option c" (the cleaner alternative to the cache-bust fix we shipped at the time). The bill came due on first prod run.
Fix
Refactor
probeSummaryto read S3 directly vialoadSummary()— same code path Phase 3's page-bundle service uses for its summary fan-in. Bypasses CF + the self-call entirely, so no subrequest limit and no 24 h s-maxage to cache-bust around.Wiring:
SummaryFetchertype +defaultSummaryFetcher(env)builder.probeSummaryandbuildCoverageReport.globalThis.fetch.Test plan
bun test test/manifest-coverage.unit.test.ts)/admin/summary/coverage; expect 0 errors, ~130 stale (every existing summary is still schema 1.0 until backfill runs)--match on*first, then--match nm*)Why ship as a follow-up not a fixup amend
#628 already merged + tagged + npm-published as v0.8.35. Amending isn't possible; this is genuinely a follow-up release.