mirror of https://github.com/actions/toolkit
cache: retry requests on HTTP 500 responses
actions/cache occasionally gets 500 errors like actions/upload-artifact does, but it just fails instead of retrying like upload-artifact does. This adds retrying on 500 errors to @actions/cache the same way it was added to @actions/artifact in #833.pull/1440/head
parent
ae38557bb0
commit
9ede666fff
|
@ -122,7 +122,7 @@ test('retry fails after exhausting retries', async () => {
|
|||
})
|
||||
|
||||
test('retry fails after non-retryable status code', async () => {
|
||||
await testRetryExpectingError([TestResponse(500), TestResponse(200, 'Ok')])
|
||||
await testRetryExpectingError([TestResponse(501), TestResponse(200, 'Ok')])
|
||||
})
|
||||
|
||||
test('retry works after error', async () => {
|
||||
|
|
|
@ -186,7 +186,7 @@ test('save with reserve cache failure should fail', async () => {
|
|||
.spyOn(cacheHttpClient, 'reserveCache')
|
||||
.mockImplementation(async () => {
|
||||
const response: TypedResponse<ReserveCacheResponse> = {
|
||||
statusCode: 500,
|
||||
statusCode: 501,
|
||||
result: null,
|
||||
headers: {}
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ test('save with server error should fail', async () => {
|
|||
.spyOn(cacheHttpClient, 'reserveCache')
|
||||
.mockImplementation(async () => {
|
||||
const response: TypedResponse<ReserveCacheResponse> = {
|
||||
statusCode: 500,
|
||||
statusCode: 501,
|
||||
result: {cacheId},
|
||||
headers: {}
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ test('save with valid inputs uploads a cache', async () => {
|
|||
.spyOn(cacheHttpClient, 'reserveCache')
|
||||
.mockImplementation(async () => {
|
||||
const response: TypedResponse<ReserveCacheResponse> = {
|
||||
statusCode: 500,
|
||||
statusCode: 501,
|
||||
result: {cacheId},
|
||||
headers: {}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ export function isRetryableStatusCode(statusCode?: number): boolean {
|
|||
return false
|
||||
}
|
||||
const retryableStatusCodes = [
|
||||
HttpCodes.InternalServerError,
|
||||
HttpCodes.BadGateway,
|
||||
HttpCodes.ServiceUnavailable,
|
||||
HttpCodes.GatewayTimeout
|
||||
|
|
Loading…
Reference in New Issue