fix(landing): degrade gracefully when a section's data can't load - #57
Conversation
`/` is the most important URL on the site, and the revamp made it query the
database on every request — guides via article-service and featured tracks via
MusicService. Any failure in either took the entire homepage down with a 500.
Confirmed in production preview: the Neon branch previews fork from is not
migrated, because scripts/migrate-deploy.mjs is production-only by design. So
`prisma.article.findMany()` fails with P2022 ("The column articles.scheduledAt
does not exist") and the whole landing page returns a server-side exception.
The production database is migrated and unaffected — /learn queries the same
table there and renders — but a homepage that hard-500s on a database hiccup
is the wrong failure mode regardless.
Both fetches now go through `safely()`, which logs and falls back. Every
section already renders an empty state, so the page degrades to that instead
of disappearing.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
The landing page revamp made
/query the database on every request. Any failure took the whole homepage down with a 500.This is not hypothetical — the
developpreview deployment is currently serving an application error:Cause:
scripts/migrate-deploy.mjsis production-only by design, so the Neon branch previews fork from was never migrated. It's missingarticles.scheduledAtand thesite_profiletable.Production is unaffected — I verified
flemoji.com/learnqueries the same table and renders fine, so the prod database is migrated. Promotion tomainwill work.Fix
Both fetches go through
safely(), which logs and returns a fallback. Every section already renders an empty state, so the page degrades to that rather than 500ing.This is the right failure mode independent of the preview drift: a marketing homepage should not disappear because the database is briefly unavailable.
Not fixed here
The preview database drift itself. Options: migrate the Neon
mainbranch, or let previews use the production database. That's an infra decision.Verification
tsc0 errors · lint 0 errors · jest 337/337 ·/renders locally.🤖 Generated with Claude Code