From 80d5f4e36a924f90e9437911bd3b1f1f4d7583e2 Mon Sep 17 00:00:00 2001 From: Mario Campos Date: Thu, 10 Sep 2026 18:48:14 -0500 Subject: [PATCH] Always clean-up temp dirs in `withTmpDir` --- src/util.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/util.ts b/src/util.ts index f6258b2853..dcd81f4655 100644 --- a/src/util.ts +++ b/src/util.ts @@ -84,9 +84,11 @@ export async function withTmpDir( body: (tmpDir: string) => Promise, ): Promise { const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "codeql-action-")); - const result = await body(tmpDir); - await fs.promises.rm(tmpDir, { force: true, recursive: true }); - return result; + try { + return await body(tmpDir); + } finally { + await fs.promises.rm(tmpDir, { force: true, recursive: true }); + } } /**