Skip to content

Commit a7c34ad

Browse files
authored
Merge pull request #894 from actions/kotewar/update-toolkit-version
Fix for the download stuck problem
2 parents f427802 + 83394c9 commit a7c34ad

7 files changed

Lines changed: 75 additions & 21 deletions

File tree

.licenses/npm/@actions/cache.dep.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ See ["Caching dependencies to speed up workflows"](https://help.github.com/githu
1717
* Fixed tar creation error while trying to create tar with path as `~/` home folder on `ubuntu-latest`.
1818
* Fixed zstd failing on amazon linux 2.0 runners
1919
* Fixed cache not working with github workspace directory or current directory
20+
* Fixed the download stuck problem by introducing a timeout of 1 hour for cache downloads.
2021

2122
Refer [here](https://github.com/actions/cache/blob/v2/README.md) for previous versions
2223

RELEASES.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@
2121

2222
### 3.0.6
2323
- Fixed [#809](https://github.com/actions/cache/issues/809) - zstd -d: no such file or directory error
24-
- Fixed [#833](https://github.com/actions/cache/issues/833) - cache doesn't work with github workspace directory
24+
- Fixed [#833](https://github.com/actions/cache/issues/833) - cache doesn't work with github workspace directory
25+
26+
### 3.0.7
27+
- Fixed [#810](https://github.com/actions/cache/issues/810) - download stuck issue. A new timeout is introduced in the download process to abort the download if it gets stuck and doesn't finish within an hour.

dist/restore/index.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5473,6 +5473,7 @@ const util = __importStar(__webpack_require__(669));
54735473
const utils = __importStar(__webpack_require__(15));
54745474
const constants_1 = __webpack_require__(931);
54755475
const requestUtils_1 = __webpack_require__(899);
5476+
const abort_controller_1 = __webpack_require__(106);
54765477
/**
54775478
* Pipes the body of a HTTP response to a stream
54785479
*
@@ -5656,15 +5657,24 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) {
56565657
const fd = fs.openSync(archivePath, 'w');
56575658
try {
56585659
downloadProgress.startDisplayTimer();
5660+
const controller = new abort_controller_1.AbortController();
5661+
const abortSignal = controller.signal;
56595662
while (!downloadProgress.isDone()) {
56605663
const segmentStart = downloadProgress.segmentOffset + downloadProgress.segmentSize;
56615664
const segmentSize = Math.min(maxSegmentSize, contentLength - segmentStart);
56625665
downloadProgress.nextSegment(segmentSize);
5663-
const result = yield client.downloadToBuffer(segmentStart, segmentSize, {
5666+
const result = yield promiseWithTimeout(options.segmentTimeoutInMs || 3600000, client.downloadToBuffer(segmentStart, segmentSize, {
5667+
abortSignal,
56645668
concurrency: options.downloadConcurrency,
56655669
onProgress: downloadProgress.onProgress()
5666-
});
5667-
fs.writeFileSync(fd, result);
5670+
}));
5671+
if (result === 'timeout') {
5672+
controller.abort();
5673+
throw new Error('Aborting cache download as the download time exceeded the timeout.');
5674+
}
5675+
else if (Buffer.isBuffer(result)) {
5676+
fs.writeFileSync(fd, result);
5677+
}
56685678
}
56695679
}
56705680
finally {
@@ -5675,6 +5685,16 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) {
56755685
});
56765686
}
56775687
exports.downloadCacheStorageSDK = downloadCacheStorageSDK;
5688+
const promiseWithTimeout = (timeoutMs, promise) => __awaiter(void 0, void 0, void 0, function* () {
5689+
let timeoutHandle;
5690+
const timeoutPromise = new Promise(resolve => {
5691+
timeoutHandle = setTimeout(() => resolve('timeout'), timeoutMs);
5692+
});
5693+
return Promise.race([promise, timeoutPromise]).then(result => {
5694+
clearTimeout(timeoutHandle);
5695+
return result;
5696+
});
5697+
});
56785698
//# sourceMappingURL=downloadUtils.js.map
56795699

56805700
/***/ }),
@@ -40795,7 +40815,8 @@ function getDownloadOptions(copy) {
4079540815
const result = {
4079640816
useAzureSdk: true,
4079740817
downloadConcurrency: 8,
40798-
timeoutInMs: 30000
40818+
timeoutInMs: 30000,
40819+
segmentTimeoutInMs: 3600000
4079940820
};
4080040821
if (copy) {
4080140822
if (typeof copy.useAzureSdk === 'boolean') {
@@ -40807,10 +40828,14 @@ function getDownloadOptions(copy) {
4080740828
if (typeof copy.timeoutInMs === 'number') {
4080840829
result.timeoutInMs = copy.timeoutInMs;
4080940830
}
40831+
if (typeof copy.segmentTimeoutInMs === 'number') {
40832+
result.segmentTimeoutInMs = copy.segmentTimeoutInMs;
40833+
}
4081040834
}
4081140835
core.debug(`Use Azure SDK: ${result.useAzureSdk}`);
4081240836
core.debug(`Download concurrency: ${result.downloadConcurrency}`);
4081340837
core.debug(`Request timeout (ms): ${result.timeoutInMs}`);
40838+
core.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`);
4081440839
return result;
4081540840
}
4081640841
exports.getDownloadOptions = getDownloadOptions;

dist/save/index.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5473,6 +5473,7 @@ const util = __importStar(__webpack_require__(669));
54735473
const utils = __importStar(__webpack_require__(15));
54745474
const constants_1 = __webpack_require__(931);
54755475
const requestUtils_1 = __webpack_require__(899);
5476+
const abort_controller_1 = __webpack_require__(106);
54765477
/**
54775478
* Pipes the body of a HTTP response to a stream
54785479
*
@@ -5656,15 +5657,24 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) {
56565657
const fd = fs.openSync(archivePath, 'w');
56575658
try {
56585659
downloadProgress.startDisplayTimer();
5660+
const controller = new abort_controller_1.AbortController();
5661+
const abortSignal = controller.signal;
56595662
while (!downloadProgress.isDone()) {
56605663
const segmentStart = downloadProgress.segmentOffset + downloadProgress.segmentSize;
56615664
const segmentSize = Math.min(maxSegmentSize, contentLength - segmentStart);
56625665
downloadProgress.nextSegment(segmentSize);
5663-
const result = yield client.downloadToBuffer(segmentStart, segmentSize, {
5666+
const result = yield promiseWithTimeout(options.segmentTimeoutInMs || 3600000, client.downloadToBuffer(segmentStart, segmentSize, {
5667+
abortSignal,
56645668
concurrency: options.downloadConcurrency,
56655669
onProgress: downloadProgress.onProgress()
5666-
});
5667-
fs.writeFileSync(fd, result);
5670+
}));
5671+
if (result === 'timeout') {
5672+
controller.abort();
5673+
throw new Error('Aborting cache download as the download time exceeded the timeout.');
5674+
}
5675+
else if (Buffer.isBuffer(result)) {
5676+
fs.writeFileSync(fd, result);
5677+
}
56685678
}
56695679
}
56705680
finally {
@@ -5675,6 +5685,16 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) {
56755685
});
56765686
}
56775687
exports.downloadCacheStorageSDK = downloadCacheStorageSDK;
5688+
const promiseWithTimeout = (timeoutMs, promise) => __awaiter(void 0, void 0, void 0, function* () {
5689+
let timeoutHandle;
5690+
const timeoutPromise = new Promise(resolve => {
5691+
timeoutHandle = setTimeout(() => resolve('timeout'), timeoutMs);
5692+
});
5693+
return Promise.race([promise, timeoutPromise]).then(result => {
5694+
clearTimeout(timeoutHandle);
5695+
return result;
5696+
});
5697+
});
56785698
//# sourceMappingURL=downloadUtils.js.map
56795699

56805700
/***/ }),
@@ -40795,7 +40815,8 @@ function getDownloadOptions(copy) {
4079540815
const result = {
4079640816
useAzureSdk: true,
4079740817
downloadConcurrency: 8,
40798-
timeoutInMs: 30000
40818+
timeoutInMs: 30000,
40819+
segmentTimeoutInMs: 3600000
4079940820
};
4080040821
if (copy) {
4080140822
if (typeof copy.useAzureSdk === 'boolean') {
@@ -40807,10 +40828,14 @@ function getDownloadOptions(copy) {
4080740828
if (typeof copy.timeoutInMs === 'number') {
4080840829
result.timeoutInMs = copy.timeoutInMs;
4080940830
}
40831+
if (typeof copy.segmentTimeoutInMs === 'number') {
40832+
result.segmentTimeoutInMs = copy.segmentTimeoutInMs;
40833+
}
4081040834
}
4081140835
core.debug(`Use Azure SDK: ${result.useAzureSdk}`);
4081240836
core.debug(`Download concurrency: ${result.downloadConcurrency}`);
4081340837
core.debug(`Request timeout (ms): ${result.timeoutInMs}`);
40838+
core.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`);
4081440839
return result;
4081540840
}
4081640841
exports.getDownloadOptions = getDownloadOptions;

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cache",
3-
"version": "3.0.6",
3+
"version": "3.0.7",
44
"private": true,
55
"description": "Cache dependencies and build outputs",
66
"main": "dist/restore/index.js",
@@ -23,7 +23,7 @@
2323
"author": "GitHub",
2424
"license": "MIT",
2525
"dependencies": {
26-
"@actions/cache": "^3.0.1",
26+
"@actions/cache": "^3.0.3",
2727
"@actions/core": "^1.7.0",
2828
"@actions/exec": "^1.1.1",
2929
"@actions/io": "^1.1.2"

0 commit comments

Comments
 (0)