Repository navigation
fix(server): report a failed read once per cause, stop caching what it emptied, list the whole sitemap - #305
Conversation
`withRetry` sent a Sentry event for every attempt it retried, at warning, and another for the outcome. A read that failed three times cost three events, and a caller that degraded the failure added a fourth. These reads run per render and nothing caches them, so a standing upstream fault billed the quota several times per page view. Each retried attempt is now a breadcrumb. The outcome is still the one event — the read that recovered, or the final failure — and it carries the attempt history, so nothing an attempt event said is lost. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
Background music, related content, the atlas body and both sitemap halves each hand-rolled the same block: retry, catch, warn, capture, fall back. Every copy captured on every failure, and `withRetry` captured the same failure again underneath it. These reads run per render and nothing caches them, so a standing upstream fault billed two events per page view per read, which is the volume server/AGENTS.md says to bound. `degrade` in error-utils.ts is that block once. It logs every failure and reports it through `warnOnce`: one event per key per isolate, and again when the failure changes kind, carrying the status and message the suppressed `withRetry` event used to. The read inside still retries, and passes `reportFailure: false` so this is the one report of its failure. Routed through it: `getMeditationSongs`, `getRelatedMeditations`, `getRelatedLectures` (whose identical card filter is now one predicate and one read), `getAtlasSeo`, `getAtlasSitemapUrls`, and the sitemap's config and content reads. The content half used to degrade with no Sentry report at all. The other warnings in atlas-client.ts — a root with no document, an off-origin or capped atlas sitemap — stand until someone fixes upstream, so they go through `warnOnce` too. `degrade` reports through `@sentry/react`, as `withRetry` already does, because error-utils.ts also reaches the browser. Both SDKs re-export one `@sentry/core`, so the tests share one `captureMessage` spy between them. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
`getLecture` sent a Sentry warning on every render of a clip whose parent lecture came back unpopulated. That gap stands until an editor publishes or syncs the parent, so the warning billed one event per view of the clip's page for as long as it stood. It now goes through `warnOnce`, keyed on the clip: one event per clip per isolate, with `console.warn` still on every render. Only the inside of the unresolved-parent branch changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
The related-content routes sent `public, max-age=300,
stale-while-revalidate=1800` on every 200, and the readers behind them
answered `[]` for a failure exactly as for an unknown id. So a SahajCloud
blip held an empty related section in browsers and the CDN for up to half
an hour after it recovered, and the route could not tell.
`getRelatedMeditations` and `getRelatedLectures` now degrade to `null`, and
keep `[]` for an answer that really is empty. `relatedAnswer` caches an
answer and sends `no-store` for `null`, as it does for a config read that
failed before the related read was made. The response body is unchanged:
an empty section is still `{ items: [] }`.
The routes had no tests. `api-routes.related.test.ts` covers both: the
cached answer, an invalid id that never reaches SahajCloud, and each
failure answering uncached. It sits beside `api-routes.test.ts` because
these routes read through `fetch` and the config global, where the
proxies there stub the SDK's `request`.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
The sitemap read 500 documents per collection and never asked whether there were more, so a collection past 500 lost its newest documents from `/sitemap.xml` with nothing to say so. Today's counts (66 pages, 121 meditations, 163 lectures) are under it; the cap was silent the day one was not. Each collection is now walked a page at a time until `hasNextPage` is false. Each page is one subrequest, so the walk stops at ten pages per collection and reports the truncation once per isolate rather than running unbounded inside a Worker request. The reads sort by id, so a document created mid-walk lands on the last page instead of shifting every later page by one; SahajCloud accepts `sort` and `page` on these reads (checked against the live API). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
`AtlasContent` read `content.events.length` and `breadcrumbs.length` straight off the `/api/atlas/seo` answer. That shape is hand-mirrored in `server/atlas-types.ts`, so a field upstream stops sending still compiles, and either read then threw in SSR — a 500 on a route `+Page.tsx` wraps in no boundary. The event page already read its own fields defensively; the region listing and the breadcrumb did not. A missing listing now renders the region with its "no classes" line, and a missing trail renders no breadcrumb. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
The warnOnce memo was one set shared by every source and emptied at 128 keys, and getAtlasSeo keyed its failures on the visitor's route. During a standing atlas 403 or 5xx a crawl sent one event per route, and every 128 routes cleared the memo, which re-armed every other source's warning too. Each source now keeps its own memo, so one source's churn re-arms only itself. degrade signs a failure by key, error type and status, and takes a separate `subject` for the log line, so getAtlasSeo passes no key: a site-wide refusal is one event per kind, the route rides in `extra`, and every render still logs the route it failed on. forgetReportedWarnings() lets each test start from a fresh isolate, so the atlas and sitemap cases go back to their natural routes and origins instead of dodging keys an earlier test reported. rest-api.md now says what the related reads do: a failure throws unless the read can do without it, and a degrade fallback that a caller must tell from an empty answer is a distinct sentinel (null). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
A sitemap file holds 50,000 URLs, and the atlas half may take 45,000 of them (SITEMAP_URL_CAP), leaving 5,000 for content. The content walk allowed 10 pages of 500 per collection, so up to 15,000 content URLs, and the two halves together could pass the limit with nothing reported: a crawler refuses an oversized file whole. Three pages per collection is 4,500 in all, and the truncation report still fires at the ceiling. A test pins the content half under 50,000 - SITEMAP_URL_CAP. getSiteAnnotation goes back to logging only. Its failure is getWebConfig's failure, and getWebConfig's own retry already reports that, so a second warning here spent two events on one cause. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-web | 0f3b767 | Commit Preview URL Branch Preview URL |
Nov 19 2026, 10:45 PM |
`(trail ?? []).length` built a throwaway array on every render just to read a length. `!trail || trail.length < 2` reads the same and allocates nothing. `trail && trail.length < 2` would invert the missing-trail case: the guard goes false, `trail.map` runs, and the render throws. The 'trail goes missing' test in AtlasContent.test.tsx fails that way. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWySWAHJp4dWwhm9Ku
|
Adopted — the breadcrumb guard, at Base merged — Gate at Security review skipped: this push's own change is under Body refreshed: the F10e bullet, the reconciliation list, and the test results. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-design | 0f3b767 | Commit Preview URL Branch Preview URL |
Nov 19 2026, 10:45 PM |
`server/AGENTS.md` names `warnOnce` as the volume bound for a new warning on a read. It reached main with #305, after this branch's base, so the memo here was a second implementation of it. The dedup key, the per-render `console.warn` and the Sentry level are unchanged. The cap moves from 64 gaps to `warnOnce`'s 128 per source. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjYS6tjaST5e7ETsP68
Summary
/sitemap.xmlreads each content collection a page at a time, so it is no longer cut off silently at 500 documents per collection. The walk stays inside the 5,000 URLs the atlas half leaves free under the 50,000-URL limit for one sitemap file.degradeinserver/error-utils.ts. It logs every failure, reports it once per key and kind of failure per isolate, and returns the fallback.warnOncekeeps a separate memo per source, so a noisy source cannot re-arm another source's warning. A failing atlas route is reported once per kind of failure, not once per crawled URL.Findings addressed
F9d — On main,
withRetrysent a warning event for each retried attempt (server/error-utils.ts:175) and an error event for the final failure (:194), and each degrading caller then reported again. Retried attempts are nowSentry.addBreadcrumbentries. The newRetryConfig.reportFailureoption (defaulttrue) lets a degraded read leave the report todegrade. Reads that propagate their failure still report it aterror. Tests:server/error-utils.test.ts›withRetry reporting(3 tests, all fail on main).F15b — Adds
degradeandwarnOncebesidewithRetry. These reads now go through them:getMeditationSongs,getRelatedMeditationsandgetRelatedLectures(their duplicated filter is nowisRenderableCard/readRelatedCards),getAtlasSeo,getAtlasSitemapUrls, and the sitemap'sgetContentSitemapUrls, which sent nothing to Sentry before. Each wrapswithRetry(read, { reportFailure: false }).Review follow-ups in this PR:
degradekeys a report on key + error type + status.degradetakes a separatesubjectfor the log line.getAtlasSeopasses no key, because up to 45,000 routes would otherwise mean up to 45,000 events in a standing 403. The route goes inextraand in every log line.forgetReportedWarnings()lets each test start from a fresh isolate.Tests:
error-utils.test.ts›warnOnce/degrade, including 'lets one source fill its memo without re-arming another source' and 'reports a keyless failure once per kind…'.atlas-client.test.ts› 'reports a standing fault once per kind, however many routes a crawl asks for'.sahajcloud-client.test.ts› 'reports %s failing once per id per isolate…' (×3).sitemap-routes.test.ts› 'reports a lost content half to Sentry, once per origin per isolate'.F9b —
getLecturecalledcaptureMessageon every render of a clip whose parent is unresolved. Only the inside of theif (!options.preview && resolved.type === 'clip' && !resolved.hlsUrl)block changed:console.warnstill runs on every render, and Sentry is reached throughwarnOncekeyed on the clip id. Test:sahajcloud-client.test.ts›getLecture› 'reports a clip with no HLS source once per isolate, and logs it every render' (fails on main).F15h — On main, the related routes (
server/api-routes.ts:271-317) sentpublic, max-age=300, stale-while-revalidate=1800on an empty answer caused by a failure.getRelatedMeditationsandgetRelatedLecturesnow returnnullfor a failure that survived the retries and[]for a real empty answer.relatedAnswer()sendsno-storefornulland when the route's own catch fires. Tests: newserver/api-routes.related.test.ts(8 tests: happy path, invalid id, upstream 5xx, real-empty 404, failed config read). The 3no-storetests fail on main.F15g — On main, the sitemap read
limit: 500per collection with nohasNextPagecheck (server/sitemap-routes.ts:30). Live counts today: pages 66, meditations 121, lectures 163.page=2andsort=idare accepted live (lectures: total 163, page 2,hasNextPage: false).readEvery()followshasNextPage, sorts by id, and stops at 3 pages per collection: 3 × 3 × 500 = 4,500 URLs, inside the 5,000 thatSITEMAP_URL_CAP(45,000) leaves free. At the cap it reports throughwarnOnce. The ceiling is marked as ashortcut:whose upgrade trigger is splitting into a sitemap index. Tests:sitemap-routes.test.ts› 'the content walk': 'lists a collection past one read, a page at a time', 'stops at its ceiling and reports the truncation…', and 'keeps the content half inside the room the atlas cap leaves in one file', which asserts≤ 50_000 - SITEMAP_URL_CAPand fails with the previous 10-page ceiling.F10e (AtlasContent half) — On main,
pages/map/_components/AtlasContent.tsxreadcontent.events.length(:166) andtrail.length(:80) without guards. The listing now uses?? [], asEventContentalready does; the trail is guarded with!trail || trail.length < 2, which reads the same and allocates nothing. Tests:AtlasContent.test.tsx› 'renders the region without classes, rather than throwing, when the listing goes missing' and '…without a breadcrumb…'. Both throw on main.Review follow-up, double report —
getSiteAnnotationlogs only, as it did on main. Its failure isgetWebConfig's failure, andgetWebConfig's own retry already reports it. Test: 'still lists the home page when the config read fails' now also asserts no warning from the sitemap.Review follow-up, docs —
docs/rules/rest-api.mdnow states the rule as it really applies: a failure throws unless the read can do without the data, and a fallback the caller must tell apart from an empty answer gets a distinct sentinel (null).server/AGENTS.mdsays adegradekey comes from a small set (an id, an origin) and never from the visitor's URL.Not in this PR
getPageLocaleStatus(server/sahajcloud-client.ts,maxAttempts: 1plus its own unboundedcaptureMessage) still reports on top ofwithRetry. It is the natural next caller ofdegrade, but it is outside this bundle's list.server/content-index.ts(owned by feat(components): a MeditationLibrary for the meditations index block #293) andserver/site-context.ts(the i18n bundle) are untouched. Both can move ontodegrade/warnOnceonce those land.AtlasContent: only the two reads the finding cites are guarded. If the wholeseo.contentobject went missing, the region, event and root renderers would still throw.public, max-age=3600, stale-while-revalidate=86400when a half fell back. This is pre-existing, and the fix is a follow-up: return a "degraded" flag from both halves and sendno-storeor a short max-age when either one fell back.Reconciled with open PRs
git merge-treeexit 0), but the two PRs disagree in meaning. Whichever of the two merges second does this reconciliation:createWarnOnce(source)(server/warn-once.ts,@sentry/cloudflare) intowarnOnce. Both now keep one memo per source, socreateWarnOnce(source)becomes(sig, msg, extra) => warnOnce(sig, msg, { source, extra }). Alternatively, move both helpers into a server-only module if browser reach matters. Both SDKs re-export the one@sentry/core.server/AGENTS.mdline "⚠ The wrapper reports each retried attempt itself, atwarning…". It is false once this PR lands, because attempts are breadcrumbs.fetchContentIndexDocsontodegradewithwithRetry(…, { reportFailure: false }).reportedConfigGapsname fromserver/AGENTS.md, since feat(components): a MeditationLibrary for the meditations index block #293 deletes it.server/sitemap-routes.tsimport lines 18-27 change only on the existing./error-utilsline (21). feat(seo): share metadata and JSON-LD at parity with the old site #282's manifest handler and its test-stub edits do not overlap.lib/atlas-head.tsxis untouched. Merge is clean.839a6de, cleanly. IngetLecture, only the inside of the unresolved-parentifblock is this PR's.839a6de.api-routes.tsedits are limited to the related routes plus one helper afterCACHE_CONTROL, and the route tests are in a new file, so the forms bundle's edits toapi-routes.test.tscannot collide.Test results
Gate
.claude/skills/pr-prep/check.shat0f3b767, withorigin/main(41079b2) merged in:tsc --noEmit: passed.pnpm buildis not required for this bundle and was not rerun for the review follow-ups. It passed at3c87a53.b9711f9also passestscandserver/tests (256 / 256).🤖 Generated with Claude Code
https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw