diff --git a/lib/utils/promise-util.js b/lib/utils/promise-util.js index be4652a..36209e2 100644 --- a/lib/utils/promise-util.js +++ b/lib/utils/promise-util.js @@ -45,6 +45,14 @@ exports.mapF = function(tasks, worker, parallelCnt) { return new Promise((resolve, reject) => { const f = () => { + // rely on worker.then(f) to check this condition + // instead of right after the while loop + // to prevent resolving the promise before the worker is done. + // This fixes parent promise misses the child promise rejection + if (nextTask === tasks.length) { + resolve(res); + } + while (runningCnt < parallelCnt && nextTask < tasks.length) { runningCnt += 1; @@ -61,10 +69,6 @@ exports.mapF = function(tasks, worker, parallelCnt) { reject(ex); }); } - - if (nextTask === tasks.length) { - resolve(res); - } }; f(); diff --git a/lib/utils/s3-util.js b/lib/utils/s3-util.js index 62b75d1..0fa5f2a 100644 --- a/lib/utils/s3-util.js +++ b/lib/utils/s3-util.js @@ -64,7 +64,7 @@ exports.uploadDir = (AWS, params) => { (f) => new Promise((resolve, reject) => { new AWS.S3().upload( { - Bucket: 'sheepcd-s3root-lmncd', + Bucket: params.s3Params.Bucket, Key: path.join( params.s3Params.Prefix, path.relative(params.localDir, f)