From 98035473adebc3bbbf93aac5638cdeed3a221b9f Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Thu, 30 Jul 2026 05:10:25 -0700 Subject: [PATCH 1/2] fix: stop tsgo backups from accumulating and breaking cached builds Co-Authored-By: Claude Fable 5 --- package.json | 2 +- scripts/clean-tsgo-backups.mjs | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 scripts/clean-tsgo-backups.mjs diff --git a/package.json b/package.json index 3f6c269aee7..839b8e79584 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "private": true, "type": "module", "scripts": { - "prepare": "effect-tsgo patch && vp config --no-agent", + "prepare": "node scripts/clean-tsgo-backups.mjs && effect-tsgo patch && vp config --no-agent", "dev": "node scripts/dev-runner.ts dev", "dev:share": "node scripts/dev-runner.ts dev --share", "dev:server": "node scripts/dev-runner.ts dev:server", diff --git a/scripts/clean-tsgo-backups.mjs b/scripts/clean-tsgo-backups.mjs new file mode 100644 index 00000000000..e319ae0aba3 --- /dev/null +++ b/scripts/clean-tsgo-backups.mjs @@ -0,0 +1,24 @@ +// Deletes stale tsgo backup files left behind by `effect-tsgo patch`. +// +// The patch command backs up the real tsgo binary to `tsgo.original`, and if +// that name is taken it writes `tsgo.original.1`, `.2`, ... without ever +// cleaning up. On runners that restore node_modules from a build cache +// (Vercel), backups accumulate across deploys until patch hard-fails at 101 +// with "Too many backup files exist". Removing them is safe: from the second +// patch onward the backup is just the previously-patched binary, and pnpm +// restores the pristine one whenever the package is re-materialized. +// +// Runs as part of `prepare`, so it must only use node builtins. +import { globSync, rmSync } from "node:fs"; + +const backups = globSync( + "node_modules/.pnpm/@typescript+native-preview-*/node_modules/@typescript/native-preview-*/lib/tsgo{,.exe}.original*", +); + +for (const backup of backups) { + rmSync(backup, { force: true }); +} + +if (backups.length > 0) { + console.log(`Removed ${backups.length} stale tsgo backup(s)`); +} From 555d37599489634b6a6452050d5449036438ef5c Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Thu, 30 Jul 2026 05:25:02 -0700 Subject: [PATCH 2/2] fix: use namespace import for node:fs per t3code lint rule Co-Authored-By: Claude Fable 5 --- scripts/clean-tsgo-backups.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/clean-tsgo-backups.mjs b/scripts/clean-tsgo-backups.mjs index e319ae0aba3..43012a69bd3 100644 --- a/scripts/clean-tsgo-backups.mjs +++ b/scripts/clean-tsgo-backups.mjs @@ -9,14 +9,14 @@ // restores the pristine one whenever the package is re-materialized. // // Runs as part of `prepare`, so it must only use node builtins. -import { globSync, rmSync } from "node:fs"; +import * as NodeFS from "node:fs"; -const backups = globSync( +const backups = NodeFS.globSync( "node_modules/.pnpm/@typescript+native-preview-*/node_modules/@typescript/native-preview-*/lib/tsgo{,.exe}.original*", ); for (const backup of backups) { - rmSync(backup, { force: true }); + NodeFS.rmSync(backup, { force: true }); } if (backups.length > 0) {