Skip to content

Commit f8b6a09

Browse files
committed
fix(docs): render raw markdown from page data, not request-time fs read
Every doc page is SSG with revalidate: 1h, so the page component re-runs on the serverless function whenever it renders outside the prerender cache (ISR revalidation, cold start, cache miss, RSC payload regeneration). The component read the raw markdown via fs.readFile(page.data._file.absolutePath) for the LLMShare copy button, but the content/docs source files are not present in the function sandbox and the baked-in build-time path does not resolve there, so the read threw and returned a 500. This surfaced as intermittent 500s on freshly deployed pages: the build-time prerendered HTML is cached at the edge (200), but the first origin hit at a cold POP — e.g. LinkedIn's crawler scraping a new changelog URL — got the 500 error page and cached it as the link preview. Use page.data.content (the raw markdown fumadocs bundles into the function), matching how lib/get-llm-text.ts already sources content for the /llms.mdx route. No filesystem access at request time, no 500.
1 parent b7a46d6 commit f8b6a09

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

app/[...slug]/page.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ts-nocheck
2-
import fs from 'node:fs/promises';
32
import defaultMdxComponents from 'fumadocs-ui/mdx';
43
import matter from 'gray-matter';
54
import * as lucideIcons from 'lucide-react';
@@ -44,8 +43,11 @@ export default async function Page(props: {
4443
}
4544

4645
if (!page) notFound();
47-
const fileContent = await fs.readFile(page.data._file.absolutePath, 'utf-8');
48-
const { content: rawMarkdownContent } = matter(fileContent);
46+
// Use the raw markdown bundled into page.data.content rather than reading the
47+
// source file from disk at request time. The content/docs source files are not
48+
// present in the serverless function sandbox, so a filesystem read throws and
49+
// returns a 500 whenever the page renders outside the prerender cache.
50+
const { content: rawMarkdownContent } = matter(page.data.content);
4951

5052
const LLMContent = rawMarkdownContent
5153
.split('\n')

0 commit comments

Comments
 (0)