From 3476ecdeca64c0c97bc0c27e940f29c12b5821b0 Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Mon, 10 Nov 2025 18:30:27 +0000 Subject: [PATCH 1/5] fix(mdx): Handle read-only filesystems during MDX compilation --- src/mdx.ts | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/mdx.ts b/src/mdx.ts index 459caea86d37f..1edec1620466e 100644 --- a/src/mdx.ts +++ b/src/mdx.ts @@ -4,7 +4,7 @@ import yaml from 'js-yaml'; import {bundleMDX} from 'mdx-bundler'; import {BinaryLike, createHash} from 'node:crypto'; import {createReadStream, createWriteStream, mkdirSync} from 'node:fs'; -import {access, cp, mkdir, opendir, readFile} from 'node:fs/promises'; +import {access, cp, mkdir, opendir, readFile, writeFile} from 'node:fs/promises'; import path from 'node:path'; // @ts-expect-error ts(2305) -- For some reason "compose" is not recognized in the types import {compose, Readable} from 'node:stream'; @@ -683,8 +683,9 @@ export async function getFileBySlug(slug: string): Promise { // 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 = false; return options; }, @@ -694,6 +695,26 @@ export async function getFileBySlug(slug: string): Promise { 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 + if (result.outputFiles && result.outputFiles.length > 0) { + // Only attempt to write during build time (when CI is set) + // At runtime in Lambda, the filesystem is read-only but files already exist + if (process.env.CI) { + try { + await Promise.all( + result.outputFiles.map(async file => { + await writeFile(file.path, file.contents); + }) + ); + } catch (e) { + // If writing fails (e.g., read-only filesystem), continue anyway + // Images should already exist from build time + } + } + } + const {code, frontmatter} = result; let mergedFrontmatter = frontmatter; From b333f0648021e4f9d9971f12e66e08ba26910d9a Mon Sep 17 00:00:00 2001 From: "Kyle a.k.a. TechSquidTV" Date: Mon, 10 Nov 2025 13:47:39 -0500 Subject: [PATCH 2/5] Update src/mdx.ts --- src/mdx.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mdx.ts b/src/mdx.ts index 1edec1620466e..5daae686f3b8a 100644 --- a/src/mdx.ts +++ b/src/mdx.ts @@ -685,7 +685,7 @@ export async function getFileBySlug(slug: string): Promise { // 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 = false; + options.write = !!process.env.CI; return options; }, From 0eebbd488cc11dd95740396a8c6ff6cfbf764142 Mon Sep 17 00:00:00 2001 From: "Kyle a.k.a. TechSquidTV" Date: Mon, 10 Nov 2025 13:47:46 -0500 Subject: [PATCH 3/5] Update src/mdx.ts --- src/mdx.ts | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/mdx.ts b/src/mdx.ts index 5daae686f3b8a..1caf979416982 100644 --- a/src/mdx.ts +++ b/src/mdx.ts @@ -698,22 +698,7 @@ export async function getFileBySlug(slug: string): Promise { // 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 - if (result.outputFiles && result.outputFiles.length > 0) { - // Only attempt to write during build time (when CI is set) - // At runtime in Lambda, the filesystem is read-only but files already exist - if (process.env.CI) { - try { - await Promise.all( - result.outputFiles.map(async file => { - await writeFile(file.path, file.contents); - }) - ); - } catch (e) { - // If writing fails (e.g., read-only filesystem), continue anyway - // Images should already exist from build time - } - } - } + const {code, frontmatter} = result; From 56a7f524f0d9eb1bdcc3efecfaf984c32c2089be Mon Sep 17 00:00:00 2001 From: Kyle Tryon Date: Mon, 10 Nov 2025 14:13:14 -0500 Subject: [PATCH 4/5] fix: lint - unused import --- src/mdx.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mdx.ts b/src/mdx.ts index 1caf979416982..7852add7f6c5a 100644 --- a/src/mdx.ts +++ b/src/mdx.ts @@ -4,7 +4,7 @@ import yaml from 'js-yaml'; import {bundleMDX} from 'mdx-bundler'; import {BinaryLike, createHash} from 'node:crypto'; import {createReadStream, createWriteStream, mkdirSync} from 'node:fs'; -import {access, cp, mkdir, opendir, readFile, writeFile} from 'node:fs/promises'; +import {access, cp, mkdir, opendir, readFile} from 'node:fs/promises'; import path from 'node:path'; // @ts-expect-error ts(2305) -- For some reason "compose" is not recognized in the types import {compose, Readable} from 'node:stream'; From 25d98f4aa8474c74b68a17c643009bb343da119e Mon Sep 17 00:00:00 2001 From: "getsantry[bot]" <66042841+getsantry[bot]@users.noreply.github.com> Date: Mon, 10 Nov 2025 19:14:04 +0000 Subject: [PATCH 5/5] [getsentry/action-github-commit] Auto commit --- src/mdx.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mdx.ts b/src/mdx.ts index 7852add7f6c5a..020af221b086a 100644 --- a/src/mdx.ts +++ b/src/mdx.ts @@ -699,7 +699,6 @@ export async function getFileBySlug(slug: string): Promise { // 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;