@@ -8,10 +8,16 @@ import {
88 mkdirSync ,
99} from "node:fs" ;
1010import { createHash } from "node:crypto" ;
11+ import { debug } from "@actions/core" ;
1112
1213const CACHE_DIR = process . env . RUNNER_TEMP || tmpdir ( ) ;
1314const FS_CACHE_TIMEOUT = 1000 * 60 * 60 * 12 ; // hours
1415
16+ function cacheDebug ( operation : string , key : string , error : unknown ) : void {
17+ const message = error instanceof Error ? error . message : String ( error ) ;
18+ debug ( `filesystem-cache: ${ operation } failed for key "${ key } ": ${ message } ` ) ;
19+ }
20+
1521function getCachePath ( key : string ) : string {
1622 const hash = createHash ( "sha1" ) . update ( key ) . digest ( "hex" ) ;
1723 return join ( CACHE_DIR , `setup-bun-${ hash } .json` ) ;
@@ -29,8 +35,8 @@ export function getCache(key: string): string | null {
2935 return readFileSync ( path , "utf8" ) ;
3036 }
3137 }
32- } catch {
33- // Fail silently; a cache miss is better than a crash
38+ } catch ( error ) {
39+ cacheDebug ( "getCache" , key , error ) ;
3440 }
3541 return null ;
3642}
@@ -45,7 +51,7 @@ export function setCache(key: string, value: string): void {
4551 mkdirSync ( CACHE_DIR , { recursive : true } ) ;
4652 }
4753 writeFileSync ( path , value , "utf8" ) ;
48- } catch {
49- // Fail silently
54+ } catch ( error ) {
55+ cacheDebug ( "setCache" , key , error ) ;
5056 }
5157}
0 commit comments