зеркало из https://github.com/electron/electron.git
build: retry hasher function if it fails first time (#30899)
* build: retry hasher function if it fails first time * Update script/release/get-url-hash.js Co-authored-by: Cheng Zhao <zcbenz@gmail.com> Co-authored-by: Cheng Zhao <zcbenz@gmail.com>
This commit is contained in:
Родитель
8f51d3e1bf
Коммит
add94f5fe6
|
@ -8,7 +8,8 @@ const lambda = new AWS.Lambda({
|
|||
region: 'us-east-1'
|
||||
});
|
||||
|
||||
module.exports = function getUrlHash (targetUrl, algorithm = 'sha256') {
|
||||
module.exports = async function getUrlHash (targetUrl, algorithm = 'sha256', attempts = 3) {
|
||||
try {
|
||||
return new Promise((resolve, reject) => {
|
||||
lambda.invoke({
|
||||
FunctionName: 'hasher',
|
||||
|
@ -28,4 +29,11 @@ module.exports = function getUrlHash (targetUrl, algorithm = 'sha256') {
|
|||
}
|
||||
});
|
||||
});
|
||||
} catch (err) {
|
||||
if (attempts > 1) {
|
||||
console.error('Failed to get URL hash for', targetUrl, 'we will retry', err);
|
||||
return getUrlHash(targetUrl, algorithm, attempts - 1);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче