1
0
Fork 0

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
Ryann Graham 2023-06-20 11:58:53 -07:00
parent ae38557bb0
commit 9ede666fff
No known key found for this signature in database
3 changed files with 5 additions and 4 deletions

View File

@ -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 () => {

View File

@ -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: {}
}

View File

@ -26,6 +26,7 @@ export function isRetryableStatusCode(statusCode?: number): boolean {
return false
}
const retryableStatusCodes = [
HttpCodes.InternalServerError,
HttpCodes.BadGateway,
HttpCodes.ServiceUnavailable,
HttpCodes.GatewayTimeout