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 () => {
|
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 () => {
|
test('retry works after error', async () => {
|
||||||
|
|
|
@ -186,7 +186,7 @@ test('save with reserve cache failure should fail', async () => {
|
||||||
.spyOn(cacheHttpClient, 'reserveCache')
|
.spyOn(cacheHttpClient, 'reserveCache')
|
||||||
.mockImplementation(async () => {
|
.mockImplementation(async () => {
|
||||||
const response: TypedResponse<ReserveCacheResponse> = {
|
const response: TypedResponse<ReserveCacheResponse> = {
|
||||||
statusCode: 500,
|
statusCode: 501,
|
||||||
result: null,
|
result: null,
|
||||||
headers: {}
|
headers: {}
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ test('save with server error should fail', async () => {
|
||||||
.spyOn(cacheHttpClient, 'reserveCache')
|
.spyOn(cacheHttpClient, 'reserveCache')
|
||||||
.mockImplementation(async () => {
|
.mockImplementation(async () => {
|
||||||
const response: TypedResponse<ReserveCacheResponse> = {
|
const response: TypedResponse<ReserveCacheResponse> = {
|
||||||
statusCode: 500,
|
statusCode: 501,
|
||||||
result: {cacheId},
|
result: {cacheId},
|
||||||
headers: {}
|
headers: {}
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ test('save with valid inputs uploads a cache', async () => {
|
||||||
.spyOn(cacheHttpClient, 'reserveCache')
|
.spyOn(cacheHttpClient, 'reserveCache')
|
||||||
.mockImplementation(async () => {
|
.mockImplementation(async () => {
|
||||||
const response: TypedResponse<ReserveCacheResponse> = {
|
const response: TypedResponse<ReserveCacheResponse> = {
|
||||||
statusCode: 500,
|
statusCode: 501,
|
||||||
result: {cacheId},
|
result: {cacheId},
|
||||||
headers: {}
|
headers: {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ export function isRetryableStatusCode(statusCode?: number): boolean {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
const retryableStatusCodes = [
|
const retryableStatusCodes = [
|
||||||
|
HttpCodes.InternalServerError,
|
||||||
HttpCodes.BadGateway,
|
HttpCodes.BadGateway,
|
||||||
HttpCodes.ServiceUnavailable,
|
HttpCodes.ServiceUnavailable,
|
||||||
HttpCodes.GatewayTimeout
|
HttpCodes.GatewayTimeout
|
||||||
|
|
Loading…
Reference in New Issue