Repository navigation
fix(marketing): prerender the sitemap again - #8128
Conversation
The sitemap has been rendered on every request since cacheComponents was turned on. Its feature-flag read went through unstable_cache, and the PostHog call inside it ends a route handler's prerender, so Next gave up and marked the route dynamic. The flag read is now a "use cache" function with the same one-minute lifetime, and the sitemap is static with a one-minute refresh, as it was before. It only reproduced with a reachable PostHog host, which is why local builds with a placeholder host stayed static.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (1)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
|
| } catch (error) { | ||
| console.error(`[site-flags] Failed to load ${flag}`, error); | ||
| return false; |
There was a problem hiding this comment.
If PostHog briefly fails after mobile has launched, this catch returns false from inside the cached function. That off value can remain cached after PostHog recovers, temporarily removing mobile from the sitemap and marking its page noindex. Keep the fallback outside the cache boundary, or avoid caching failed reads.
Knowledge Base Used:
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/marketing/src/lib/site-flags.ts
Line: 20-22
Comment:
**Failed flag reads stay cached**
If PostHog briefly fails after mobile has launched, this catch returns `false` from inside the cached function. That off value can remain cached after PostHog recovers, temporarily removing mobile from the sitemap and marking its page `noindex`. Keep the fallback outside the cache boundary, or avoid caching failed reads.
**Knowledge Base Used:**
- [Marketing product site](https://app.greptile.com/personal-org-6810/-/custom-context/knowledge-base/superset-sh/superset/-/docs/marketing-product-site.md)
- [Marketing routes and content delivery](https://app.greptile.com/personal-org-6810/-/custom-context/knowledge-base/superset-sh/superset/-/docs/marketing-routes-and-content-delivery.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Why
Since #8101 the production sitemap is rendered on every request (
ƒ /sitemap.xmlin the build log, CDN miss on every fetch). Before, it was a static file refreshed on an interval.Cause
The sitemap reads the mobile-launch flag through
unstable_cache. WithcacheComponentson, the PostHog request inside it ends a route handler's prerender, so Next marks the route dynamic. It only happens when the PostHog host is reachable, which is why my local builds with a placeholder host stayed static.What changes
getSiteFlagis a"use cache"function with the same one-minute lifetime. A failed read still returnsfalse.Verified locally
ƒ /sitemap.xmlbefore the change,○ /sitemap.xml 1mafter./mobile, a profile and a 404 behave as before.Not verified
x-vercel-cacheheader, which only exist after merge.Summary by cubic
Restores prerendering for the production sitemap, which has been rendered on every request since
cacheComponentswas enabled. The feature-flag read went throughunstable_cache, and the PostHog call inside it ended the route handler's prerender, so Next marked the route dynamic.getSiteFlagis now a"use cache"function with the same one-minute lifetime, and a failed read still returnsfalse. The sitemap is static again with a one-minute refresh.Verified locally with a reachable PostHog host (
ƒ /sitemap.xmlbefore,○ /sitemap.xml 1mafter) and with the API unreachable at build (static, no profile URLs until refresh). Production build log and livex-vercel-cacheheader can only be checked after merge.Written for commit 5cb2fa7. Summary will update on new commits.
Summary by CodeRabbit
false.