节点asynchronous脚本有时会意外结束

我有一个节点脚本调用很多进程打包文件。 大多数情况下,这种方法很好,但是偶尔也可能(每5次电话中平均有1次),它只停在中间,总是在同一个地方。 具体而言,失败时的日志结尾如下所示:

Finished task 1! Compiling jsajax.js... Compiling apps.js... 

我没有得到任何错误或任何东西,所以我不知道甚至看什么。 这里的设置是我的主文件(index.js)使用co和生成器来调用所需的asynchronous进程,并产生结果。 其中的一部分是吞噬,这是发生这个问题的地方。 我在这里包含了调用代码和gulp任务,因为剩下的代码太长,无法显示所有内容。 如果您认为需要的话,我很高兴收录更多。 谢谢!

调用函数:

 const createJS = function* createJS () { try { yield gulpFile.createJS(); return 0; } catch(err) { console.error(err); return CONSTANTS.ERROR; } }; 

吞噬任务:

 const createJS = function () { const buildProps = PropertiesReader('build.properties'), distLoc = buildProps.get('distLoc'), installLoc = buildProps.get('installLoc'), updateLoc = buildProps.get('updateLoc'), installJSLoc = `${installLoc}/js`, updateJSLoc = `${updateLoc}/js`, jsajax = CONSTANTS.JSAJAX_FILES.map(file => distLoc + file), appsOnly = CONSTANTS.APPS_FILES.map(file => distLoc + file), apps = [...jsajax, ...appsOnly]; let compile1, compile2; compile1 = new Promise((resolve, reject) => { console.log('Compiling jsajax.js...'); gulp.src(jsajax) .pipe(sourcemaps.init()) .pipe(concat('jsajax.js')) .pipe(uglify()) .pipe(sourcemaps.write('./')) .pipe(gulp.dest(installJSLoc)) .pipe(gulp.dest(updateJSLoc)) .on('error', err => reject(err)) .on('end', () => { console.log('jsajax.js compiled successfully!'); resolve(); }); }); compile2 = new Promise((resolve, reject) => { console.log('Compiling apps.js...'); gulp.src(apps) .pipe(sourcemaps.init()) .pipe(concat('apps.js')) .pipe(uglify()) .pipe(sourcemaps.write('./')) .pipe(gulp.dest(installJSLoc)) .pipe(gulp.dest(updateJSLoc)) .on('error', err => reject(err)) .on('end', () => { console.log('apps.js compiled successfully!'); resolve(); }); }); return Promise.all([compile1, compile2]); };