From 678f278caaca8797ea292b621c4b0bc33b757d7f Mon Sep 17 00:00:00 2001 From: Dave Hadka Date: Tue, 3 Nov 2020 09:53:44 -0600 Subject: [PATCH] Handle non-successful responses from uploadChunk --- packages/cache/src/internal/cacheHttpClient.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/cache/src/internal/cacheHttpClient.ts b/packages/cache/src/internal/cacheHttpClient.ts index 77954e94..dab39115 100644 --- a/packages/cache/src/internal/cacheHttpClient.ts +++ b/packages/cache/src/internal/cacheHttpClient.ts @@ -194,7 +194,7 @@ async function uploadChunk( 'Content-Range': getContentRange(start, end) } - await retryHttpClientResponse( + const uploadChunkResponse = await retryHttpClientResponse( `uploadChunk (start: ${start}, end: ${end})`, async () => httpClient.sendStream( @@ -204,6 +204,12 @@ async function uploadChunk( additionalHeaders ) ) + + if (!isSuccessStatusCode(uploadChunkResponse.message.statusCode)) { + throw new Error( + `Cache service responded with ${uploadChunkResponse.message.statusCode} during upload chunk.` + ) + } } async function uploadFile(