@@ -2997,7 +2997,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
2997
2997
return (mod && mod.__esModule) ? mod : { "default": mod };
2998
2998
};
2999
2999
Object.defineProperty(exports, "__esModule", ({ value: true }));
3000
- exports.getConcurrency = exports.getGitHubWorkspaceDir = exports.isGhes = exports.getResultsServiceUrl = exports.getRuntimeToken = exports.getUploadChunkSize = void 0;
3000
+ exports.getUploadChunkTimeout = exports. getConcurrency = exports.getGitHubWorkspaceDir = exports.isGhes = exports.getResultsServiceUrl = exports.getRuntimeToken = exports.getUploadChunkSize = void 0;
3001
3001
const os_1 = __importDefault(__nccwpck_require__(22037));
3002
3002
// Used for controlling the highWaterMark value of the zip that is being streamed
3003
3003
// The same value is used as the chunk size that is use during upload to blob storage
@@ -3050,6 +3050,10 @@ function getConcurrency() {
3050
3050
return concurrency > 300 ? 300 : concurrency;
3051
3051
}
3052
3052
exports.getConcurrency = getConcurrency;
3053
+ function getUploadChunkTimeout() {
3054
+ return 30000; // 30 seconds
3055
+ }
3056
+ exports.getUploadChunkTimeout = getUploadChunkTimeout;
3053
3057
//# sourceMappingURL=config.js.map
3054
3058
3055
3059
/***/ }),
@@ -3298,37 +3302,34 @@ function uploadZipToBlobStorage(authenticatedUploadURL, zipUploadStream) {
3298
3302
return __awaiter(this, void 0, void 0, function* () {
3299
3303
let uploadByteCount = 0;
3300
3304
let lastProgressTime = Date.now();
3301
- let timeoutId;
3302
- const chunkTimer = (timeout) => {
3303
- // clear the previous timeout
3304
- if (timeoutId) {
3305
- clearTimeout(timeoutId);
3306
- }
3307
- timeoutId = setTimeout(() => {
3308
- const now = Date.now();
3309
- // if there's been more than 30 seconds since the
3310
- // last progress event, then we'll consider the upload stalled
3311
- if (now - lastProgressTime > timeout) {
3312
- throw new Error('Upload progress stalled.');
3313
- }
3314
- }, timeout);
3315
- return timeoutId;
3316
- };
3305
+ const abortController = new AbortController();
3306
+ const chunkTimer = (interval) => __awaiter(this, void 0, void 0, function* () {
3307
+ return new Promise((resolve, reject) => {
3308
+ const timer = setInterval(() => {
3309
+ if (Date.now() - lastProgressTime > interval) {
3310
+ reject(new Error('Upload progress stalled.'));
3311
+ }
3312
+ }, interval);
3313
+ abortController.signal.addEventListener('abort', () => {
3314
+ clearInterval(timer);
3315
+ resolve();
3316
+ });
3317
+ });
3318
+ });
3317
3319
const maxConcurrency = (0, config_1.getConcurrency)();
3318
3320
const bufferSize = (0, config_1.getUploadChunkSize)();
3319
3321
const blobClient = new storage_blob_1.BlobClient(authenticatedUploadURL);
3320
3322
const blockBlobClient = blobClient.getBlockBlobClient();
3321
- const timeoutDuration = 300000; // 30 seconds
3322
3323
core.debug(`Uploading artifact zip to blob storage with maxConcurrency: ${maxConcurrency}, bufferSize: ${bufferSize}`);
3323
3324
const uploadCallback = (progress) => {
3324
3325
core.info(`Uploaded bytes ${progress.loadedBytes}`);
3325
3326
uploadByteCount = progress.loadedBytes;
3326
- chunkTimer(timeoutDuration);
3327
3327
lastProgressTime = Date.now();
3328
3328
};
3329
3329
const options = {
3330
3330
blobHTTPHeaders: { blobContentType: 'zip' },
3331
- onProgress: uploadCallback
3331
+ onProgress: uploadCallback,
3332
+ abortSignal: abortController.signal
3332
3333
};
3333
3334
let sha256Hash = undefined;
3334
3335
const uploadStream = new stream.PassThrough();
@@ -3337,9 +3338,10 @@ function uploadZipToBlobStorage(authenticatedUploadURL, zipUploadStream) {
3337
3338
zipUploadStream.pipe(hashStream).setEncoding('hex'); // This stream is used to compute a hash of the zip content that gets used. Integrity check
3338
3339
core.info('Beginning upload of artifact content to blob storage');
3339
3340
try {
3340
- // Start the chunk timer
3341
- timeoutId = chunkTimer(timeoutDuration);
3342
- yield blockBlobClient.uploadStream(uploadStream, bufferSize, maxConcurrency, options);
3341
+ yield Promise.race([
3342
+ blockBlobClient.uploadStream(uploadStream, bufferSize, maxConcurrency, options),
3343
+ chunkTimer((0, config_1.getUploadChunkTimeout)())
3344
+ ]);
3343
3345
}
3344
3346
catch (error) {
3345
3347
if (errors_1.NetworkError.isNetworkErrorCode(error === null || error === void 0 ? void 0 : error.code)) {
@@ -3348,10 +3350,7 @@ function uploadZipToBlobStorage(authenticatedUploadURL, zipUploadStream) {
3348
3350
throw error;
3349
3351
}
3350
3352
finally {
3351
- // clear the timeout whether or not the upload completes
3352
- if (timeoutId) {
3353
- clearTimeout(timeoutId);
3354
- }
3353
+ abortController.abort();
3355
3354
}
3356
3355
core.info('Finished uploading artifact content to blob storage!');
3357
3356
hashStream.end();
@@ -3778,7 +3777,6 @@ exports.createZipUploadStream = exports.ZipUploadStream = exports.DEFAULT_COMPRE
3778
3777
const stream = __importStar(__nccwpck_require__(12781));
3779
3778
const archiver = __importStar(__nccwpck_require__(43084));
3780
3779
const core = __importStar(__nccwpck_require__(42186));
3781
- const fs_1 = __nccwpck_require__(57147);
3782
3780
const config_1 = __nccwpck_require__(74610);
3783
3781
exports.DEFAULT_COMPRESSION_LEVEL = 6;
3784
3782
// Custom stream transformer so we can set the highWaterMark property
@@ -3810,7 +3808,7 @@ function createZipUploadStream(uploadSpecification, compressionLevel = exports.D
3810
3808
for (const file of uploadSpecification) {
3811
3809
if (file.sourcePath !== null) {
3812
3810
// Add a normal file to the zip
3813
- zip.append((0, fs_1.createReadStream)( file.sourcePath) , {
3811
+ zip.file( file.sourcePath, {
3814
3812
name: file.destinationPath
3815
3813
});
3816
3814
}
@@ -136152,7 +136150,7 @@ module.exports = index;
136152
136150
/***/ ((module) => {
136153
136151
136154
136152
"use strict";
136155
- module.exports = JSON.parse('{"name":"@actions/artifact","version":"2.1.8","preview":true,"description":"Actions artifact lib","keywords":["github","actions","artifact"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/artifact","license":"MIT","main":"lib/artifact.js","types":"lib/artifact.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/artifact"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"cd ../../ && npm run test ./packages/artifact","bootstrap":"cd ../../ && npm run bootstrap","tsc-run":"tsc","tsc":"npm run bootstrap && npm run tsc-run","gen:docs":"typedoc --plugin typedoc-plugin-markdown --out docs/generated src/artifact.ts --githubPages false --readme none"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.10.0","@actions/github":"^5.1.1","@actions/http-client":"^2.1.0","@azure/storage-blob":"^12.15.0","@octokit/core":"^3.5.1","@octokit/plugin-request-log":"^1.0.4","@octokit/plugin-retry":"^3.0.9","@octokit/request-error":"^5.0.0","@protobuf-ts/plugin":"^2.2.3-alpha.1","archiver":"^7.0.1","crypto":"^1.0.1","jwt-decode":"^3.1.2","twirp-ts":"^2.5.0","unzip-stream":"^0.3.1"},"devDependencies":{"@types/archiver":"^5.3.2","@types/unzip-stream":"^0.3.4","typedoc":"^0.25.4","typedoc-plugin-markdown":"^3.17.1","typescript":"^5.2.2"}}');
136153
+ module.exports = JSON.parse('{"name":"@actions/artifact","version":"2.1.9","preview":true,"description":"Actions artifact lib","keywords":["github","actions","artifact"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/artifact","license":"MIT","main":"lib/artifact.js","types":"lib/artifact.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/artifact"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"cd ../../ && npm run test ./packages/artifact","bootstrap":"cd ../../ && npm run bootstrap","tsc-run":"tsc","tsc":"npm run bootstrap && npm run tsc-run","gen:docs":"typedoc --plugin typedoc-plugin-markdown --out docs/generated src/artifact.ts --githubPages false --readme none"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.10.0","@actions/github":"^5.1.1","@actions/http-client":"^2.1.0","@azure/storage-blob":"^12.15.0","@octokit/core":"^3.5.1","@octokit/plugin-request-log":"^1.0.4","@octokit/plugin-retry":"^3.0.9","@octokit/request-error":"^5.0.0","@protobuf-ts/plugin":"^2.2.3-alpha.1","archiver":"^7.0.1","crypto":"^1.0.1","jwt-decode":"^3.1.2","twirp-ts":"^2.5.0","unzip-stream":"^0.3.1"},"devDependencies":{"@types/archiver":"^5.3.2","@types/unzip-stream":"^0.3.4","typedoc":"^0.25.4","typedoc-plugin-markdown":"^3.17.1","typescript":"^5.2.2"}}');
136156
136154
136157
136155
/***/ }),
136158
136156
0 commit comments