Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/mdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,9 @@ export async function getFileBySlug(slug: string): Promise<SlugFile> {
// for this specific slug easily
options.outdir = assetsCacheDir || outdir;

// Set write to true so that esbuild will output the files.
options.write = true;
// Set write to false to prevent esbuild from writing files automatically.
// We'll handle writing manually to gracefully handle read-only filesystems (e.g., Lambda runtime)
options.write = !!process.env.CI;
Copy link

Choose a reason for hiding this comment

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

Bug: Dynamic Assets Unwritten in Runtime

Setting options.write = false in non-CI environments prevents esbuild from writing output files, but there's no code to manually write result.outputFiles when write is false. In Lambda/runtime environments, assetsCacheDir is null, so the copy operation at line 721 doesn't execute, leaving generated assets (images, etc.) unwritten. This breaks dynamic content that wasn't pre-built.

Fix in Cursor Fix in Web

Copy link
Contributor

Choose a reason for hiding this comment

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

@cursoragent can you break down what is being written, where it was being written, and what its purpose was. Was this recently changed?

Copy link

Choose a reason for hiding this comment

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

You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor


return options;
},
Expand All @@ -694,6 +695,10 @@ export async function getFileBySlug(slug: string): Promise<SlugFile> {
throw e;
});

// Manually write output files from esbuild when available
// This only happens during build time (when filesystem is writable)
// At runtime (Lambda), files already exist from build time

const {code, frontmatter} = result;

let mergedFrontmatter = frontmatter;
Expand Down
Loading