From 178a58237455b2bc489e979d0dd387f97b9c631b Mon Sep 17 00:00:00 2001 From: whywaita Date: Mon, 10 Apr 2023 16:02:17 +0900 Subject: [PATCH] Fix missing error handle --- dist/restore/index.js | 149 +++++++++++++++++++----------------------- dist/save/index.js | 149 +++++++++++++++++++----------------------- package-lock.json | 31 ++++----- package.json | 2 +- 4 files changed, 155 insertions(+), 176 deletions(-) diff --git a/dist/restore/index.js b/dist/restore/index.js index f51b66c..fd3ec69 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -8164,6 +8164,9 @@ function getCacheEntryS3(s3Options, s3BucketName, keys, paths) { throw new Error(`Error from S3: ${e}`); } if (!response.Contents) { + if (contents.length != 0) { + break; + } throw new Error(`Cannot found object in bucket ${s3BucketName}`); } core.debug(`Found objects ${response.Contents.length}`); @@ -30281,7 +30284,7 @@ exports.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS = { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.convertMap = exports.map = void 0; +exports.take = exports.convertMap = exports.map = void 0; function map(arg0, arg1, arg2) { let target; let filter; @@ -30306,25 +30309,7 @@ function map(arg0, arg1, arg2) { target[key] = instructions[key]; continue; } - let [filter, value] = instructions[key]; - if (typeof value === "function") { - let _value; - const defaultFilterPassed = filter === undefined && (_value = value()) != null; - const customFilterPassed = (typeof filter === "function" && !!filter(void 0)) || (typeof filter !== "function" && !!filter); - if (defaultFilterPassed) { - target[key] = _value; - } - else if (customFilterPassed) { - target[key] = value(); - } - } - else { - const defaultFilterPassed = filter === undefined && value != null; - const customFilterPassed = (typeof filter === "function" && !!filter(value)) || (typeof filter !== "function" && !!filter); - if (defaultFilterPassed || customFilterPassed) { - target[key] = value; - } - } + applyInstruction(target, null, instructions, key); } return target; } @@ -30337,6 +30322,14 @@ const convertMap = (target) => { return output; }; exports.convertMap = convertMap; +const take = (source, instructions) => { + const out = {}; + for (const key in instructions) { + applyInstruction(out, source, instructions, key); + } + return out; +}; +exports.take = take; const mapWithFilter = (target, filter, instructions) => { return map(target, Object.entries(instructions).reduce((_instructions, [key, value]) => { if (Array.isArray(value)) { @@ -30353,6 +30346,40 @@ const mapWithFilter = (target, filter, instructions) => { return _instructions; }, {})); }; +const applyInstruction = (target, source, instructions, targetKey) => { + if (source !== null) { + let instruction = instructions[targetKey]; + if (typeof instruction === "function") { + instruction = [, instruction]; + } + const [filter = nonNullish, valueFn = pass, sourceKey = targetKey] = instruction; + if ((typeof filter === "function" && filter(source[sourceKey])) || (typeof filter !== "function" && !!filter)) { + target[targetKey] = valueFn(source[sourceKey]); + } + return; + } + let [filter, value] = instructions[targetKey]; + if (typeof value === "function") { + let _value; + const defaultFilterPassed = filter === undefined && (_value = value()) != null; + const customFilterPassed = (typeof filter === "function" && !!filter(void 0)) || (typeof filter !== "function" && !!filter); + if (defaultFilterPassed) { + target[targetKey] = _value; + } + else if (customFilterPassed) { + target[targetKey] = value(); + } + } + else { + const defaultFilterPassed = filter === undefined && value != null; + const customFilterPassed = (typeof filter === "function" && !!filter(value)) || (typeof filter !== "function" && !!filter); + if (defaultFilterPassed || customFilterPassed) { + target[targetKey] = value; + } + } +}; +const nonNullish = (_) => _ != null; +const pass = (_) => _; /***/ }), @@ -94081,11 +94108,11 @@ var crypto = __webpack_require__(417); // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -var _a; +var _a$1; /** * A constant that indicates whether the environment the code is running is Node.JS. */ -const isNode = typeof process !== "undefined" && Boolean(process.version) && Boolean((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node); +const isNode = typeof process !== "undefined" && Boolean(process.version) && Boolean((_a$1 = process.versions) === null || _a$1 === void 0 ? void 0 : _a$1.node); // Copyright (c) Microsoft Corporation. /** @@ -94276,6 +94303,22 @@ function objectHasProperty(thing, property) { return (isDefined(thing) && typeof thing === "object" && property in thing); } +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +var _a; +// NOTE: This is a workaround until we can use `globalThis.crypto.randomUUID` in Node.js 19+. +const uuidFunction = typeof ((_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.crypto) === null || _a === void 0 ? void 0 : _a.randomUUID) === "function" + ? globalThis.crypto.randomUUID.bind(globalThis.crypto) + : crypto.randomUUID; +/** + * Generated Universally Unique Identifier + * + * @returns RFC4122 v4 UUID. + */ +function randomUUID() { + return uuidFunction(); +} + exports.computeSha256Hash = computeSha256Hash; exports.computeSha256Hmac = computeSha256Hmac; exports.createAbortablePromise = createAbortablePromise; @@ -94288,6 +94331,7 @@ exports.isNode = isNode; exports.isObject = isObject; exports.isObjectWithProperties = isObjectWithProperties; exports.objectHasProperty = objectHasProperty; +exports.randomUUID = randomUUID; //# sourceMappingURL=index.js.map @@ -98040,6 +98084,7 @@ Object.defineProperty(exports, '__esModule', { value: true }); var logger$1 = __webpack_require__(492); var abortController = __webpack_require__(819); +var coreUtil = __webpack_require__(900); // Copyright (c) Microsoft Corporation. /** @@ -98288,7 +98333,7 @@ function transformStatus(inputs) { case "cancelled": return "canceled"; default: { - logger.warning(`LRO: unrecognized operation status: ${status}`); + logger.verbose(`LRO: unrecognized operation status: ${status}`); return status; } } @@ -98449,58 +98494,6 @@ async function pollHttpOperation(inputs) { }); } -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. -/** - * Map an optional value through a function - * @internal - */ -const maybemap = (value, f) => value === undefined ? undefined : f(value); -const INTERRUPTED = new Error("The poller is already stopped"); -/** - * A promise that delays resolution until a certain amount of time (in milliseconds) has passed, with facilities for - * robust cancellation. - * - * ### Example: - * - * ```javascript - * let toCancel; - * - * // Wait 20 seconds, and optionally allow the function to be cancelled. - * await delayMs(20000, (cancel) => { toCancel = cancel }); - * - * // ... if `toCancel` is called before the 20 second timer expires, then the delayMs promise will reject. - * ``` - * - * @internal - * @param ms - the number of milliseconds to wait before resolving - * @param cb - a callback that can provide the caller with a cancellation function - */ -function delayMs(ms) { - let aborted = false; - let toReject; - return Object.assign(new Promise((resolve, reject) => { - let token; - toReject = () => { - maybemap(token, clearTimeout); - reject(INTERRUPTED); - }; - // In the rare case that the operation is _already_ aborted, we will reject instantly. This could happen, for - // example, if the user calls the cancellation function immediately without yielding execution. - if (aborted) { - toReject(); - } - else { - token = setTimeout(resolve, ms); - } - }), { - cancel: () => { - aborted = true; - toReject === null || toReject === void 0 ? void 0 : toReject(); - }, - }); -} - // Copyright (c) Microsoft Corporation. const createStateProxy$1 = () => ({ /** @@ -98553,7 +98546,6 @@ function buildCreatePoller(inputs) { setErrorAsResult: !resolveOnUnsuccessful, }); let resultPromise; - let cancelJob; const abortController$1 = new abortController.AbortController(); const handlers = new Map(); const handleProgressEvents = async () => handlers.forEach((h) => h(state)); @@ -98566,7 +98558,6 @@ function buildCreatePoller(inputs) { isStopped: () => resultPromise === undefined, stopPolling: () => { abortController$1.abort(); - cancelJob === null || cancelJob === void 0 ? void 0 : cancelJob(); }, toString: () => JSON.stringify({ state, @@ -98584,9 +98575,7 @@ function buildCreatePoller(inputs) { if (!poller.isDone()) { await poller.poll({ abortSignal }); while (!poller.isDone()) { - const delay = delayMs(currentPollIntervalInMs); - cancelJob = delay.cancel; - await delay; + await coreUtil.delay(currentPollIntervalInMs, { abortSignal }); await poller.poll({ abortSignal }); } } diff --git a/dist/save/index.js b/dist/save/index.js index 9967e07..95cf19c 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -8164,6 +8164,9 @@ function getCacheEntryS3(s3Options, s3BucketName, keys, paths) { throw new Error(`Error from S3: ${e}`); } if (!response.Contents) { + if (contents.length != 0) { + break; + } throw new Error(`Cannot found object in bucket ${s3BucketName}`); } core.debug(`Found objects ${response.Contents.length}`); @@ -30344,7 +30347,7 @@ exports.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS = { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.convertMap = exports.map = void 0; +exports.take = exports.convertMap = exports.map = void 0; function map(arg0, arg1, arg2) { let target; let filter; @@ -30369,25 +30372,7 @@ function map(arg0, arg1, arg2) { target[key] = instructions[key]; continue; } - let [filter, value] = instructions[key]; - if (typeof value === "function") { - let _value; - const defaultFilterPassed = filter === undefined && (_value = value()) != null; - const customFilterPassed = (typeof filter === "function" && !!filter(void 0)) || (typeof filter !== "function" && !!filter); - if (defaultFilterPassed) { - target[key] = _value; - } - else if (customFilterPassed) { - target[key] = value(); - } - } - else { - const defaultFilterPassed = filter === undefined && value != null; - const customFilterPassed = (typeof filter === "function" && !!filter(value)) || (typeof filter !== "function" && !!filter); - if (defaultFilterPassed || customFilterPassed) { - target[key] = value; - } - } + applyInstruction(target, null, instructions, key); } return target; } @@ -30400,6 +30385,14 @@ const convertMap = (target) => { return output; }; exports.convertMap = convertMap; +const take = (source, instructions) => { + const out = {}; + for (const key in instructions) { + applyInstruction(out, source, instructions, key); + } + return out; +}; +exports.take = take; const mapWithFilter = (target, filter, instructions) => { return map(target, Object.entries(instructions).reduce((_instructions, [key, value]) => { if (Array.isArray(value)) { @@ -30416,6 +30409,40 @@ const mapWithFilter = (target, filter, instructions) => { return _instructions; }, {})); }; +const applyInstruction = (target, source, instructions, targetKey) => { + if (source !== null) { + let instruction = instructions[targetKey]; + if (typeof instruction === "function") { + instruction = [, instruction]; + } + const [filter = nonNullish, valueFn = pass, sourceKey = targetKey] = instruction; + if ((typeof filter === "function" && filter(source[sourceKey])) || (typeof filter !== "function" && !!filter)) { + target[targetKey] = valueFn(source[sourceKey]); + } + return; + } + let [filter, value] = instructions[targetKey]; + if (typeof value === "function") { + let _value; + const defaultFilterPassed = filter === undefined && (_value = value()) != null; + const customFilterPassed = (typeof filter === "function" && !!filter(void 0)) || (typeof filter !== "function" && !!filter); + if (defaultFilterPassed) { + target[targetKey] = _value; + } + else if (customFilterPassed) { + target[targetKey] = value(); + } + } + else { + const defaultFilterPassed = filter === undefined && value != null; + const customFilterPassed = (typeof filter === "function" && !!filter(value)) || (typeof filter !== "function" && !!filter); + if (defaultFilterPassed || customFilterPassed) { + target[targetKey] = value; + } + } +}; +const nonNullish = (_) => _ != null; +const pass = (_) => _; /***/ }), @@ -94085,11 +94112,11 @@ var crypto = __webpack_require__(417); // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -var _a; +var _a$1; /** * A constant that indicates whether the environment the code is running is Node.JS. */ -const isNode = typeof process !== "undefined" && Boolean(process.version) && Boolean((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node); +const isNode = typeof process !== "undefined" && Boolean(process.version) && Boolean((_a$1 = process.versions) === null || _a$1 === void 0 ? void 0 : _a$1.node); // Copyright (c) Microsoft Corporation. /** @@ -94280,6 +94307,22 @@ function objectHasProperty(thing, property) { return (isDefined(thing) && typeof thing === "object" && property in thing); } +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +var _a; +// NOTE: This is a workaround until we can use `globalThis.crypto.randomUUID` in Node.js 19+. +const uuidFunction = typeof ((_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.crypto) === null || _a === void 0 ? void 0 : _a.randomUUID) === "function" + ? globalThis.crypto.randomUUID.bind(globalThis.crypto) + : crypto.randomUUID; +/** + * Generated Universally Unique Identifier + * + * @returns RFC4122 v4 UUID. + */ +function randomUUID() { + return uuidFunction(); +} + exports.computeSha256Hash = computeSha256Hash; exports.computeSha256Hmac = computeSha256Hmac; exports.createAbortablePromise = createAbortablePromise; @@ -94292,6 +94335,7 @@ exports.isNode = isNode; exports.isObject = isObject; exports.isObjectWithProperties = isObjectWithProperties; exports.objectHasProperty = objectHasProperty; +exports.randomUUID = randomUUID; //# sourceMappingURL=index.js.map @@ -98044,6 +98088,7 @@ Object.defineProperty(exports, '__esModule', { value: true }); var logger$1 = __webpack_require__(492); var abortController = __webpack_require__(819); +var coreUtil = __webpack_require__(900); // Copyright (c) Microsoft Corporation. /** @@ -98292,7 +98337,7 @@ function transformStatus(inputs) { case "cancelled": return "canceled"; default: { - logger.warning(`LRO: unrecognized operation status: ${status}`); + logger.verbose(`LRO: unrecognized operation status: ${status}`); return status; } } @@ -98453,58 +98498,6 @@ async function pollHttpOperation(inputs) { }); } -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. -/** - * Map an optional value through a function - * @internal - */ -const maybemap = (value, f) => value === undefined ? undefined : f(value); -const INTERRUPTED = new Error("The poller is already stopped"); -/** - * A promise that delays resolution until a certain amount of time (in milliseconds) has passed, with facilities for - * robust cancellation. - * - * ### Example: - * - * ```javascript - * let toCancel; - * - * // Wait 20 seconds, and optionally allow the function to be cancelled. - * await delayMs(20000, (cancel) => { toCancel = cancel }); - * - * // ... if `toCancel` is called before the 20 second timer expires, then the delayMs promise will reject. - * ``` - * - * @internal - * @param ms - the number of milliseconds to wait before resolving - * @param cb - a callback that can provide the caller with a cancellation function - */ -function delayMs(ms) { - let aborted = false; - let toReject; - return Object.assign(new Promise((resolve, reject) => { - let token; - toReject = () => { - maybemap(token, clearTimeout); - reject(INTERRUPTED); - }; - // In the rare case that the operation is _already_ aborted, we will reject instantly. This could happen, for - // example, if the user calls the cancellation function immediately without yielding execution. - if (aborted) { - toReject(); - } - else { - token = setTimeout(resolve, ms); - } - }), { - cancel: () => { - aborted = true; - toReject === null || toReject === void 0 ? void 0 : toReject(); - }, - }); -} - // Copyright (c) Microsoft Corporation. const createStateProxy$1 = () => ({ /** @@ -98557,7 +98550,6 @@ function buildCreatePoller(inputs) { setErrorAsResult: !resolveOnUnsuccessful, }); let resultPromise; - let cancelJob; const abortController$1 = new abortController.AbortController(); const handlers = new Map(); const handleProgressEvents = async () => handlers.forEach((h) => h(state)); @@ -98570,7 +98562,6 @@ function buildCreatePoller(inputs) { isStopped: () => resultPromise === undefined, stopPolling: () => { abortController$1.abort(); - cancelJob === null || cancelJob === void 0 ? void 0 : cancelJob(); }, toString: () => JSON.stringify({ state, @@ -98588,9 +98579,7 @@ function buildCreatePoller(inputs) { if (!poller.isDone()) { await poller.poll({ abortSignal }); while (!poller.isDone()) { - const delay = delayMs(currentPollIntervalInMs); - cancelJob = delay.cancel; - await delay; + await coreUtil.delay(currentPollIntervalInMs, { abortSignal }); await poller.poll({ abortSignal }); } } diff --git a/package-lock.json b/package-lock.json index 42180e8..3780c8a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,8 +5,8 @@ "requires": true, "dependencies": { "@actions/cache": { - "version": "https://gitpkg.now.sh/whywaita/toolkit/packages/cache?5d6dba0", - "integrity": "sha512-DMTeCU4TCSFO/7vSHNbBfry5aFIy3z6jpNOGTdXwGHKhGR6ImmWx6syNpX3//E8XR0hmAcubTiNRS9mNE8X5KA==", + "version": "https://gitpkg.now.sh/whywaita/toolkit/packages/cache?d423a21", + "integrity": "sha512-UHZ4yceZ3nrEASQ4fOlEgeDEm+HI73wPkbk1Hax3wyjg7RP8KB0qyaRDPOQs+FOUWgpkVi9gwZLn13j/XtOdgw==", "requires": { "@actions/core": "^1.2.6", "@actions/exec": "^1.0.1", @@ -681,12 +681,12 @@ } }, "@aws-sdk/lib-storage": { - "version": "3.306.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/lib-storage/-/lib-storage-3.306.0.tgz", - "integrity": "sha512-/XPTLZ39gxaQGpcZhYW+o/cKpkELt94Exurs/2YSjNv0BiTueDLoY8pPMkXeuspOKlcPLQneX2HnjbvaQXjUhQ==", + "version": "3.309.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/lib-storage/-/lib-storage-3.309.0.tgz", + "integrity": "sha512-dKAnJNmNs0yTAslGcU/bJ6zf1EuCy+p00XvgRnt4nQSLhp9jk+c3P6nhfD5EpA7wN1La30DK6oCuFX2Pb13YnA==", "requires": { "@aws-sdk/middleware-endpoint": "3.306.0", - "@aws-sdk/smithy-client": "3.306.0", + "@aws-sdk/smithy-client": "3.309.0", "buffer": "5.6.0", "events": "3.3.0", "stream-browserify": "3.0.0", @@ -702,9 +702,9 @@ } }, "@aws-sdk/smithy-client": { - "version": "3.306.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/smithy-client/-/smithy-client-3.306.0.tgz", - "integrity": "sha512-AFdNkto0Md6laio9t70WtvocoZqVcAydbY5csimXQh+lhKVmy/C+ZcKarDvaa0JD6PjSHb4snYzcINFpHW5LJQ==", + "version": "3.309.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/smithy-client/-/smithy-client-3.309.0.tgz", + "integrity": "sha512-2+LJD8/J9yoYmfjLZuMTI/IF8qFMMclWdDJaalj4Rzzd7qBWDS3Q23UxpZi9VR155nqpgr/R+TFZMgze1EhRHg==", "requires": { "@aws-sdk/middleware-stack": "3.306.0", "@aws-sdk/types": "3.306.0", @@ -1656,11 +1656,12 @@ } }, "@azure/core-lro": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@azure/core-lro/-/core-lro-2.5.1.tgz", - "integrity": "sha512-JHQy/bA3NOz2WuzOi5zEk6n/TJdAropupxUT521JIJvW7EXV2YN2SFYZrf/2RHeD28QAClGdynYadZsbmP+nyQ==", + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/@azure/core-lro/-/core-lro-2.5.2.tgz", + "integrity": "sha512-tucUutPhBwCPu6v16KEFYML81npEL6gnT+iwewXvK5ZD55sr0/Vw2jfQETMiKVeARRrXHB2QQ3SpxxGi1zAUWg==", "requires": { "@azure/abort-controller": "^1.0.0", + "@azure/core-util": "^1.2.0", "@azure/logger": "^1.0.0", "tslib": "^2.2.0" }, @@ -1704,9 +1705,9 @@ } }, "@azure/core-util": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@azure/core-util/-/core-util-1.2.0.tgz", - "integrity": "sha512-ffGIw+Qs8bNKNLxz5UPkz4/VBM/EZY07mPve1ZYFqYUdPwFqRj0RPk0U7LZMOfT7GCck9YjuT1Rfp1PApNl1ng==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@azure/core-util/-/core-util-1.3.0.tgz", + "integrity": "sha512-ANP0Er7R2KHHHjwmKzPF9wbd0gXvOX7yRRHeYL1eNd/OaNrMLyfZH/FQasHRVAf6rMXX+EAUpvYwLMFDHDI5Gw==", "requires": { "@azure/abort-controller": "^1.0.0", "tslib": "^2.2.0" diff --git a/package.json b/package.json index f7385e7..1b7d2cd 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "author": "GitHub", "license": "MIT", "dependencies": { - "@actions/cache": "https://gitpkg.now.sh/whywaita/toolkit/packages/cache?5d6dba0", + "@actions/cache": "https://gitpkg.now.sh/whywaita/toolkit/packages/cache?d423a21", "@actions/core": "^1.2.6", "@actions/exec": "^1.0.1", "@actions/io": "^1.1.0",