New error type for cache RL

This commit is contained in:
Ryan Ghadimi
2026-01-16 10:00:15 +00:00
parent 7292b3508f
commit dd1bb93c72
3 changed files with 14 additions and 8 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
### 5.0.3
Fail cache saves on rate limit errors from the cache service to prevent slowing down impacted runs [2243](https://github.com/actions/toolkit/pull/2243).
Fail cache operations on rate limit errors from the cache service to prevent slowing down impacted runs [2243](https://github.com/actions/toolkit/pull/2243).
### 5.0.1
+6 -7
View File
@@ -1,6 +1,6 @@
import {info, debug, warning} from '@actions/core'
import {getUserAgentString} from './user-agent'
import {NetworkError, UsageError} from './errors'
import {NetworkError, RateLimitError, UsageError} from './errors'
import {getCacheServiceURL} from '../config'
import {getRuntimeToken} from '../cacheUtils'
import {BearerCredentialHandler} from '@actions/http-client/lib/auth'
@@ -121,7 +121,7 @@ class CacheServiceClient implements Rpc {
)
}
}
throw new Error(`Rate limited: ${errorMessage}`)
throw new RateLimitError(`Rate limited: ${errorMessage}`)
}
} catch (error) {
if (error instanceof SyntaxError) {
@@ -132,13 +132,12 @@ class CacheServiceClient implements Rpc {
throw error
}
if (NetworkError.isNetworkErrorCode(error?.code)) {
throw new NetworkError(error?.code)
if (error instanceof RateLimitError) {
throw error
}
// Re-throw rate limit errors without retry
if (error.message?.startsWith('Rate limited:')) {
throw error
if (NetworkError.isNetworkErrorCode(error?.code)) {
throw new NetworkError(error?.code)
}
isRetryable = true
+7
View File
@@ -70,3 +70,10 @@ export class UsageError extends Error {
return msg.includes('insufficient usage')
}
}
export class RateLimitError extends Error {
constructor(message: string) {
super(message)
this.name = 'RateLimitError'
}
}