Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Fails with Large Number of Markdown Files (100k+) in Astro Project #12888

Open
1 task
pantickatorce opened this issue Jan 3, 2025 · 4 comments
Open
1 task
Labels
feat: content collections Related to the Content Collections feature (scope) needs repro Issue needs a reproduction

Comments

@pantickatorce
Copy link

pantickatorce commented Jan 3, 2025

Astro Info

✅ Astro 5.1.0
✅ Node v20.17.0

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

I'm struggling with an issue when running npm run build locally. The process fails, and I'm at my wit's end trying to fix it. My project has more than 100,000 .md files in the content folder, and I use getCollection("posts") in several places. I've already tried increasing memory limits with --max-old-space-size=12288 and many other tweaks, but nothing seems to work.

The website is intended to be fully static on the server, and I need the entire dist folder to be generated.

Is there any solution for this? I’m really desperate at this point.

Thank you so much in advance!

Console:

`23:47:12 [build] Collecting build info...
23:47:12 [build] ✓ Completed in 37.32s.
23:47:12 [build] Building static entrypoints...

<--- Last few GCs --->

[18644:000002071B902880]   216506 ms: Mark-Compact (reduce) 4080.4 (4138.7) -> 4080.4 (4139.2) MB, 654.26 / 0.02 ms  (+ 98.4 ms in 10 steps since start of marking, biggest step 1
= 0.545, current [18644:000002071B902880]   218604 ms: Mark-Compact (reduce) 4096.9 (4155.2) -> 4086.6 (4145.4) MB, 1847.77 / 0.00 ms  (average mu = 0.305, current mu = 0.119) al


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

 1: 00007FF762A239EB node::SetCppgcReference+18459
 2: 00007FF762993238 DSA_meth_get_flags+93160
 3: 00007FF76340C771 v8::Isolate::ReportExternalAllocationLimitReached+65
 4: 00007FF7633F5EC8 v8::Function::Experimental_IsNopFunction+1336
 5: 00007FF763257970 v8::Platform::SystemClockTimeMillis+659328
 6: 00007FF7632549F8 v8::Platform::SystemClockTimeMillis+647176
 7: 00007FF763269D0A v8::Platform::SystemClockTimeMillis+733978
 8: 00007FF76326A587 v8::Platform::SystemClockTimeMillis+736151
criptor::writable+678094
12: 00007FF6E3C2735D
error: script "build" exited with code 134`

What's the expected result?

All dist archives

Link to Minimal Reproducible Example

https://pantic14.com/

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jan 3, 2025
@Yuelioi
Copy link

Yuelioi commented Jan 6, 2025

I have the same issue, so I decided to use dynamic rendering, just like WordPress.

@ematipico
Copy link
Member

ematipico commented Jan 7, 2025

@pantickatorce have you considered using the new content collections using the new loader API? https://docs.astro.build/en/guides/content-collections/#built-in-loaders

@ascorbic
Copy link
Contributor

ascorbic commented Jan 8, 2025

If the site is using 5.1.0 then it will be using content layer unless specifically disabled, so I don't think there's much scope for improvement there.

We need a reproduction if we're to do anything about this, though I think that it may end up just being that 100k pages needs lots of memory whatever's happening.

@ascorbic ascorbic added - P2: nice to have Not breaking anything but nice to have (priority) feat: content collections Related to the Content Collections feature (scope) needs repro Issue needs a reproduction and removed needs triage Issue needs to be triaged - P2: nice to have Not breaking anything but nice to have (priority) labels Jan 8, 2025
Copy link
Contributor

github-actions bot commented Jan 8, 2025

Hello @pantickatorce. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro will be closed if they have no activity within 3 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: content collections Related to the Content Collections feature (scope) needs repro Issue needs a reproduction
Projects
None yet
Development

No branches or pull requests

4 participants