Skip to content

Commit c392952

Browse files
fix(scripts): remove the patch-check temp dir when interrupted
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent f5e62c7 commit c392952

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎scripts/check-changed.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ const runPatchCheck = files.some(
234234
// Cached registry metadata limits this to patches stranded by local changes, not registry drift.
235235
const checkPatches = async () => {
236236
const temp = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-patch-check-"));
237+
// The signal handlers exit before this function's finally can run.
238+
const cleanup = () => NodeFS.rmSync(temp, { recursive: true, force: true });
239+
process.once("exit", cleanup);
237240
try {
238241
const copy = (relative: string) => {
239242
const dest = NodePath.join(temp, relative);
@@ -263,7 +266,8 @@ const checkPatches = async () => {
263266
"or pin the dependency that pulls it in to the patched version.\n";
264267
return { ...result, output: Buffer.concat([result.output, Buffer.from(hint)]) };
265268
} finally {
266-
NodeFS.rmSync(temp, { recursive: true, force: true });
269+
process.removeListener("exit", cleanup);
270+
cleanup();
267271
}
268272
};
269273

0 commit comments

Comments
 (0)