Add deferRender option to glob() loader to prevent OOM during content sync#17302
Open
astrobot-houston wants to merge 3 commits into
Open
Add deferRender option to glob() loader to prevent OOM during content sync#17302astrobot-houston wants to merge 3 commits into
deferRender option to glob() loader to prevent OOM during content sync#17302astrobot-houston wants to merge 3 commits into
Conversation
…ring content sync
When glob() processes .md files, it eagerly renders them and stores the
full HTML in the data store. For content with heavy rehype plugins (e.g.
KaTeX), rendered HTML can be ~70x larger than source, exhausting memory
for large collections.
This adds a deferRender option to glob() that skips eager rendering and
instead defers it until the entry is actually rendered in a page, matching
the existing behavior for .mdx files.
Usage: glob({ pattern: '**/*.md', base: 'src/content/docs', deferRender: true })
Fixes #17301
1 task
🦋 Changeset detectedLatest commit: 9b37f73 The changes in this PR will be included in the next version bump. This PR includes changesets to release 395 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
I'm not sure if eager rendering is even done on purpose in the first place. |
Member
To me this feels like a bug |
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.
Changes
deferRender?: booleanoption to theglob()loader. Whentrue, renderable content entries (e.g. Markdown) skip eager rendering during content sync and instead use the same deferred-render path that.mdxfiles already use — rendering happens on demand at page build time via the Vite markdown plugin.astro buildfor large Markdown collections that use heavy rehype plugins likerehype-katex, where rendered HTML can be 70× larger than source. Closes Astro build runs out of memory during content sync for large Starlight docs site with heavy KaTeX #17301.// todo: add an explicit way to opt in to deferred renderingcomment that tracked this gap since the Content Layer was introduced.Testing
glob-loader.test.tscover eager rendering (default), deferred rendering whendeferRender: true, and that non-renderable data entries are unaffected.node --max-old-space-size=256 astro buildagainst a 200-file KaTeX-heavy fixture. The build previously OOM'd; withdeferRender: trueit succeeds. Confirmed working by the issue reporter (@integrable).Docs