Skip to content

Commit

Permalink
Merge pull request #471 from spowelljr/FixCrashOnCacheFailure
Browse files Browse the repository at this point in the history
Fix crashing if cache upload fails
  • Loading branch information
medyagh authored Jun 17, 2024
2 parents d024097 + 9c1625b commit a24127d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ const exec_1 = __nccwpck_require__(1514);
const fs_1 = __nccwpck_require__(7147);
const os_1 = __nccwpck_require__(2037);
const path_1 = __nccwpck_require__(1017);
// Catch and log any unhandled exceptions. These exceptions can leak out of the
// uploadChunk method in @actions/toolkit when a failed upload closes the file
// descriptor causing any in-process reads to throw an uncaught exception.
// Instead of failing this action, just warn.
process.on('uncaughtException', (e) => {
(0, core_1.info)(`[warning]${e.message}`);
});
const restoreCaches = () => __awaiter(void 0, void 0, void 0, function* () {
const cacheHits = { iso: true, kic: true, preload: true };
if (!useCache()) {
Expand Down
10 changes: 9 additions & 1 deletion src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@ import {
restoreCache as restoreCacheAction,
saveCache as saveCacheAction,
} from '@actions/cache'
import {getInput as getInputAction} from '@actions/core'
import {info, getInput as getInputAction} from '@actions/core'
import {exec} from '@actions/exec'
import {existsSync} from 'fs'
import {arch, homedir} from 'os'
import {join} from 'path'

// Catch and log any unhandled exceptions. These exceptions can leak out of the
// uploadChunk method in @actions/toolkit when a failed upload closes the file
// descriptor causing any in-process reads to throw an uncaught exception.
// Instead of failing this action, just warn.
process.on('uncaughtException', (e) => {
info(`[warning]${e.message}`)
})

type CacheHits = {
iso: boolean
kic: boolean
Expand Down

0 comments on commit a24127d

Please sign in to comment.