Skip to content

Switch rehype-mermaid to client-side rendering to fix Astro 6 OOM#10070

Closed
Copilot wants to merge 2 commits into
mainfrom
copilot/investigate-astro-memory-usage
Closed

Switch rehype-mermaid to client-side rendering to fix Astro 6 OOM#10070
Copilot wants to merge 2 commits into
mainfrom
copilot/investigate-astro-memory-usage

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 18, 2026

Astro 6 migration caused OOM during website builds. Root cause: rehype-mermaid defaults to inline-svg strategy, which launches a headless Playwright/Chromium browser at build time to server-side render diagrams. Combined with Astro 6's higher baseline memory, this exceeded limits. There is exactly one mermaid diagram in the entire site.

Changes

  • website/astro.config.mjs: Switch rehype-mermaid to pre-mermaid strategy (no browser spawn). Add conditional client-side mermaid.js loader that only fetches the library on pages with diagrams:
    [rehypeMermaid, { strategy: "pre-mermaid" }]
  • website/package.json: Remove NODE_OPTIONS="--max-old-space-size=8192" workaround from build:web

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • telemetry.astro.build
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/typespec/typespec/website/node_modules/.bin/../astro/bin/astro.mjs build sh tool�� ebsite/src/conte--llmstxt node pec/node_modules../../website/src/content/docs/docs/emitters/openapi3/reference ld.json && pnpm node grep /.bin/node sh /nod�� node scripts/generate-version.js sh de_modules/pnpm/dist/node-gyp-bin/sh ental ture tools/pnpm/10.30doc node (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Investigate astro 6 extra memory usage</issue_title>
<issue_description>Migrating to astro 6 caused OOM error, increasing to 8GB solve the issue but maybe we should investigate why and if we can reduce that</issue_description>

<agent_instructions>Investiage if there is something in the ./website setup that would cause this out of memory error, might need to revert the change to the build script to insrease the memory</agent_instructions>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…t-side rendering

The rehype-mermaid plugin was using the default 'inline-svg' strategy which
launches a headless Playwright/Chromium browser during build to render mermaid
diagrams server-side. Combined with Astro 6's higher baseline memory usage,
this caused OOM errors requiring an 8GB memory limit workaround.

Changes:
- Switch rehype-mermaid to 'pre-mermaid' strategy (no browser needed)
- Add client-side mermaid.js script that only loads on pages with diagrams
- Remove NODE_OPTIONS --max-old-space-size=8192 from build script

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the meta:website TypeSpec.io updates label Mar 18, 2026
Copilot AI changed the title [WIP] [ISSUE-XXX] Investigate astro 6 extra memory usage Switch rehype-mermaid to client-side rendering to fix Astro 6 OOM Mar 18, 2026
Copilot AI requested a review from timotheeguerin March 18, 2026 18:32
@microsoft-github-policy-service microsoft-github-policy-service Bot added the stale Mark a PR that hasn't been recently updated and will be closed. label Apr 18, 2026
@microsoft-github-policy-service
Copy link
Copy Markdown
Contributor

Hi @@copilot. Your PR has had no update for 30 days and it is marked as a stale PR. If it is not updated within 30 days, the PR will automatically be closed. If you want to refresh the PR, please remove the stale label.

@microsoft-github-policy-service
Copy link
Copy Markdown
Contributor

Hi @@copilot. The PR will be closed since the PR has no update for 60 days. If this is still relevant please reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta:website TypeSpec.io updates stale Mark a PR that hasn't been recently updated and will be closed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate astro 6 extra memory usage

2 participants