Skip to content

Conversation

@BYK
Copy link
Member

@BYK BYK commented Jun 27, 2025

Old version ignored the assets put under public/mdx-images causing missing images. This version fixes the issue and brings build times back down to around 11 minutes.

May need a cache-busting redeploy once this merges (seen issues on develop-docs) but once we do that, the errors should go away.

@vercel
Copy link

vercel bot commented Jun 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
develop-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 28, 2025 7:05am
sentry-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 28, 2025 7:05am

@codecov
Copy link

codecov bot commented Jun 27, 2025

Bundle Report

Changes will increase total bundle size by 863.85kB (4.09%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sentry-docs-server-cjs* 11.8MB 863.85kB (7.9%) ⬆️
sentry-docs-client-array-push 9.8MB -6 bytes (-0.0%) ⬇️

ℹ️ *Bundle size includes cached data from a previous commit

Affected Assets, Files, and Routes:

view changes for bundle: sentry-docs-server-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
1729.js -3 bytes 1.64MB -0.0%
../instrumentation.js -3 bytes 973.36kB -0.0%
9523.js -3 bytes 949.31kB -0.0%
../app/[[...path]]/page.js.nft.json 287.32kB 691.58kB 71.07% ⚠️
../app/platform-redirect/page.js.nft.json 287.32kB 691.5kB 71.09% ⚠️
../app/sitemap.xml/route.js.nft.json 287.32kB 689.47kB 71.45% ⚠️
../app/[[...path]]/page.js 190 bytes 591.61kB 0.03%
../app/sitemap.xml/route.js 355 bytes 34.28kB 1.05%
../app/platform-redirect/page.js 190 bytes 31.66kB 0.6%
9567.js 1.18kB 20.62kB 6.05% ⚠️

Files in 9567.js:

  • ./src/mdx.ts → Total Size: 23.76kB

App Routes Affected:

App Route Size Change Total Size Change (%)
/platform-redirect 190 bytes 2.58MB 0.01%
/ 355 bytes 2.61MB 0.01%
/[[...path]] 190 bytes 3.14MB 0.01%
view changes for bundle: sentry-docs-client-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
static/chunks/pages/_app-*.js -3 bytes 873.24kB -0.0%
static/chunks/7750-*.js -3 bytes 415.85kB -0.0%
server/middleware-*.js -5.55kB 1.0kB -84.74%
server/middleware-*.js 5.55kB 6.55kB 555.3% ⚠️
static/1nHkFDwWdLGi1nL-*.js (New) 77 bytes 77 bytes 100.0% 🚀
static/1nHkFDwWdLGi1nL-*.js (New) 684 bytes 684 bytes 100.0% 🚀
static/poUYE-*.js (Deleted) -77 bytes 0 bytes -100.0% 🗑️
static/poUYE-*.js (Deleted) -684 bytes 0 bytes -100.0% 🗑️

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR restores MDX caching by writing compressed cache files and cached assets to a .next/cache/mdx-bundler directory and switches from the React cache helper to an in-memory Map for per-process caching.

  • Adds Brotli‐compressed cache read/write functions and cache directory setup
  • Wraps image bundler output into a cache directory and reuses it on CI
  • Replaces react cache with a simple Map for getFileBySlugWithCache

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/mdx.ts Implements cache directory, compression, and in-process cache
scripts/generate-md-exports.mjs Guards against undefined response.Contents when iterating
Comments suppressed due to low confidence (1)

src/mdx.ts:67

  • [nitpick] Consider adding unit tests for readCacheFile and writeCacheFile to validate that cache files are correctly compressed, decompressed, and handled under CI conditions.
async function readCacheFile<T>(file: string): Promise<T> {

BYK and others added 2 commits June 27, 2025 23:08
cursor[bot]

This comment was marked as outdated.

@BYK BYK enabled auto-merge (squash) June 27, 2025 22:17
@BYK BYK closed this Jun 28, 2025
auto-merge was automatically disabled June 28, 2025 06:49

Pull request was closed

@BYK BYK reopened this Jun 28, 2025
cursor[bot]

This comment was marked as outdated.

@BYK BYK enabled auto-merge (squash) June 28, 2025 06:54
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Cache Writing Fails on Missing Directory

The cp operation, used for copying assets to the public directory during cache writing, throws an uncaught error if its source directory (assetsCacheDir) does not exist. This occurs when esbuild processes MDX files that do not generate any assets, as esbuild only creates the output directory when it has files to write. This uncaught error causes the getFileBySlug function to fail, potentially crashing the build process. Unlike the cache reading logic, the cache writing logic does not gracefully handle the absence of this directory.

src/mdx.ts#L684-L685

sentry-docs/src/mdx.ts

Lines 684 to 685 in 377a562

if (assetsCacheDir && cacheFile) {
await cp(assetsCacheDir, outdir, {recursive: true});

Fix in Cursor


Was this report helpful? Give feedback by reacting with 👍 or 👎

@BYK BYK merged commit 18b187e into master Jun 28, 2025
15 checks passed
@BYK BYK deleted the byk/ci/mdx-cache-re branch June 28, 2025 07:05
bitsandfoxes pushed a commit that referenced this pull request Jul 3, 2025
Old version ignored the assets put under `public/mdx-images` causing
missing images. This version fixes the issue and brings build times back
down to around 11 minutes.

May need a cache-busting redeploy once this merges (seen issues on
`develop-docs`) but once we do that, the errors should go away.

---------

Co-authored-by: Copilot <[email protected]>
@github-actions github-actions bot locked and limited conversation to collaborators Jul 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants