Skip to content

Commit

Permalink
Merge pull request actions#624 from actions/dhadka/upload-chunk-error
Browse files Browse the repository at this point in the history
Handle non-successful responses from uploadChunk
  • Loading branch information
dhadka authored Nov 3, 2020
2 parents f1b118b + 5e8657c commit 5e5e1b7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
4 changes: 4 additions & 0 deletions packages/cache/RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@
- Use http-client v1.0.9
- Fixes error handling so retries are not attempted on non-retryable errors (409 Conflict, for example)
- Adds 5 second delay between retry attempts

### 1.0.4
- Use @actions/core v1.2.6
- Fixes uploadChunk to throw an error if any unsuccessful response code is received
8 changes: 4 additions & 4 deletions packages/cache/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/cache/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@actions/cache",
"version": "1.0.3",
"version": "1.0.4",
"preview": true,
"description": "Actions cache lib",
"keywords": [
Expand Down Expand Up @@ -37,7 +37,7 @@
"url": "https://github.com/actions/toolkit/issues"
},
"dependencies": {
"@actions/core": "^1.2.4",
"@actions/core": "^1.2.6",
"@actions/exec": "^1.0.1",
"@actions/glob": "^0.1.0",
"@actions/http-client": "^1.0.9",
Expand Down
8 changes: 7 additions & 1 deletion packages/cache/src/internal/cacheHttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down

0 comments on commit 5e5e1b7

Please sign in to comment.