New error type for cache RL
This commit is contained in:
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
### 5.0.3
|
### 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
|
### 5.0.1
|
||||||
|
|
||||||
|
|||||||
+6
-7
@@ -1,6 +1,6 @@
|
|||||||
import {info, debug, warning} from '@actions/core'
|
import {info, debug, warning} from '@actions/core'
|
||||||
import {getUserAgentString} from './user-agent'
|
import {getUserAgentString} from './user-agent'
|
||||||
import {NetworkError, UsageError} from './errors'
|
import {NetworkError, RateLimitError, UsageError} from './errors'
|
||||||
import {getCacheServiceURL} from '../config'
|
import {getCacheServiceURL} from '../config'
|
||||||
import {getRuntimeToken} from '../cacheUtils'
|
import {getRuntimeToken} from '../cacheUtils'
|
||||||
import {BearerCredentialHandler} from '@actions/http-client/lib/auth'
|
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) {
|
} catch (error) {
|
||||||
if (error instanceof SyntaxError) {
|
if (error instanceof SyntaxError) {
|
||||||
@@ -132,13 +132,12 @@ class CacheServiceClient implements Rpc {
|
|||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NetworkError.isNetworkErrorCode(error?.code)) {
|
if (error instanceof RateLimitError) {
|
||||||
throw new NetworkError(error?.code)
|
throw error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-throw rate limit errors without retry
|
if (NetworkError.isNetworkErrorCode(error?.code)) {
|
||||||
if (error.message?.startsWith('Rate limited:')) {
|
throw new NetworkError(error?.code)
|
||||||
throw error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isRetryable = true
|
isRetryable = true
|
||||||
|
|||||||
@@ -70,3 +70,10 @@ export class UsageError extends Error {
|
|||||||
return msg.includes('insufficient usage')
|
return msg.includes('insufficient usage')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class RateLimitError extends Error {
|
||||||
|
constructor(message: string) {
|
||||||
|
super(message)
|
||||||
|
this.name = 'RateLimitError'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user