Skip to content

Navigation Menu

Sign up

Build Failing in CI Due to Memory Issues (~14k MD files) – Works Locally #11745

Unanswered
TaushifAli1 asked this question in Q&A
Discussion options

Hi everyone,

We’re running into memory issues when building our Docusaurus site in CI and would appreciate some guidance.

Context

  • Docusaurus version: 3.8.1
    -Node version: 22
    -Docs size: ~14,000 markdown files
  • Build output size (local): ~805 MB
  • CI environment: Our own GitHub runner with 32 GB RAM
  • experimental_faster: enabled

Problem

The build works fine locally, but it fails in GitHub Actions due to memory issues.

We are using our own runner with 32 GB RAM, so we were not expecting memory to be a bottleneck.
What We’ve Tried

  1. Increased Node heap:
    node --max-old-space-size=16384

Still failing. Given that the runner has 32 GB RAM, we suspect this might not be the real issue.

2.Added swap space in CI:
pierotofy/set-swap-space

This does allow the build to succeed.
However:

  • This feels like a temporary workaround.
  • With continued content growth, this likely won’t scale.

We did memory analysis, we are seeing ram is eaten up during docusaurus build (this is without swap space)

Screenshot 2026年02月15日 at 11 15 09 AM
You must be logged in to vote

Replies: 2 comments

Comment options

Hey 👋

It's impossible to help with this kind of issue without knowing more about your site and having access to its source.

Set DOCUSAURUS_PERF_LOGGER=true to see what takes time, locally and on GitHub, then share with us the full log.

Why do you have 14k md files? Are they written manually or codegen?

We have recently found out that codegen of large mdx documents can be a huge problem for performance. An OpenAPI plugin changed its strategy and became much faster. #11664

You must be logged in to vote
0 replies
Comment options

Had this exact issue with large doc builds crashing in CI while passing locally on my laptop.

The reason it passes on your local machine with less RAM but fails on a 32GB CI runner comes down to CPU core count.

Self-hosted CI runners usually have 16 or 32 vCPU cores. Docusaurus and Webpack spawn worker threads based on os.cpus().length. When Webpack parses 14,000 markdown files across 16+ parallel workers, each worker eats 1.5GB to 2GB of RAM, easily blowing past 32GB. Your local laptop likely has 4 to 8 cores, so it spawns fewer workers and stays well under the memory limit.

Here is how to stabilize the build:

1. Limit worker thread count in CI

Tell Node and Webpack not to use every single core on the host runner. In your CI workflow step, cap the thread pool:

env:
 UV_THREADPOOL_SIZE: 4
run: npm run build -- --parallelism 4

2. Check for local search plugins

If you are using a local full-text search plugin like docusaurus-search-local or docusaurus-lunr-search, building an index for 14,000 markdown files in memory is a massive RAM spike.

Try running a test build with the search plugin temporarily commented out in docusaurus.config.js. If memory drops by half, configure the search plugin to skip indexing in CI or switch to an external search provider (like Algolia DocSearch) so indexing does not happen during the webpack compile.

Give the worker cap a try first, that usually resolves the runner OOM immediately.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /