From 818affc3593e9beb58d54a03a62197280d3624bc Mon Sep 17 00:00:00 2001 From: Kevin Stillhammer Date: Sun, 31 May 2026 11:25:35 +0200 Subject: [PATCH] fix: report unexpected cache save failures (#896) ## Summary - add top-level uncaughtException and unhandledRejection handlers for the save-cache entrypoint - report unexpected post-action failures through core.setFailed with stack/context - regenerate the committed save-cache bundle --- dist/save-cache/index.cjs | 16 ++++++++++++++++ src/save-cache.ts | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/dist/save-cache/index.cjs b/dist/save-cache/index.cjs index d6ee52d..4e73da0 100644 --- a/dist/save-cache/index.cjs +++ b/dist/save-cache/index.cjs @@ -63211,6 +63211,22 @@ function getResolutionStrategy() { } // src/save-cache.ts +function formatUnexpectedFailure(error2) { + if (error2 instanceof Error) { + return error2.stack ?? error2.message; + } + return String(error2); +} +function failUnexpectedly(event, error2) { + setFailed(`${event}: ${formatUnexpectedFailure(error2)}`); + process.exit(1); +} +process.on("uncaughtException", (error2) => { + failUnexpectedly("Uncaught exception", error2); +}); +process.on("unhandledRejection", (reason) => { + failUnexpectedly("Unhandled promise rejection", reason); +}); async function run() { try { const inputs = loadInputs(); diff --git a/src/save-cache.ts b/src/save-cache.ts index 366ae69..c957ff4 100644 --- a/src/save-cache.ts +++ b/src/save-cache.ts @@ -11,6 +11,26 @@ import { import { STATE_UV_PATH, STATE_UV_VERSION } from "./utils/constants"; import { loadInputs, type SetupInputs } from "./utils/inputs"; +function formatUnexpectedFailure(error: unknown): string { + if (error instanceof Error) { + return error.stack ?? error.message; + } + return String(error); +} + +function failUnexpectedly(event: string, error: unknown): never { + core.setFailed(`${event}: ${formatUnexpectedFailure(error)}`); + process.exit(1); +} + +process.on("uncaughtException", (error) => { + failUnexpectedly("Uncaught exception", error); +}); + +process.on("unhandledRejection", (reason) => { + failUnexpectedly("Unhandled promise rejection", reason); +}); + export async function run(): Promise { try { const inputs = loadInputs();