From 719fa59e98c059a5e3d0fe968b51a30fff94326c Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Wed, 22 Nov 2023 13:24:21 +0300 Subject: [PATCH] [bug] Set timeout for entire conversion(wait results uploading); Remove result dir to reduce amount of data transferred in case of error --- FileConverter/sources/converter.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/FileConverter/sources/converter.js b/FileConverter/sources/converter.js index 29982f6f..252d4eee 100644 --- a/FileConverter/sources/converter.js +++ b/FileConverter/sources/converter.js @@ -40,6 +40,7 @@ var config = require('config'); var spawnAsync = require('@expo/spawn-async'); const bytes = require('bytes'); const lcid = require('lcid'); +const ms = require('ms'); var commonDefines = require('./../../Common/sources/commondefines'); var storage = require('./../../Common/sources/storage-base'); @@ -787,6 +788,10 @@ function* processUploadToStorageErrorFile(ctx, dataConvert, tempDirs, childRes, let outputPath = path.join(tempDirs.temp, 'console.txt'); fs.writeFileSync(outputPath, output, {encoding: 'utf8'}); + //remove result dir with temp dir inside(see m_sTempDir param) to reduce the amount of data transferred + //todo filter on upload + fs.rmSync(tempDirs.result, { recursive: true, force: true }); + let format = path.extname(dataConvert.fileFrom).substring(1) || "unknown"; yield* processUploadToStorage(ctx, tempDirs.temp, format + '/' + dataConvert.key , false, tenErrorFiles); @@ -919,7 +924,7 @@ function* spawnProcess(ctx, builderParams, tempDirs, dataConvert, authorProps, g } let spawnAsyncPromise = spawnAsync(processPath, childArgs, spawnOptions); childRes = spawnAsyncPromise.child; - let waitMS = task.getVisibilityTimeout() * 1000 - (new Date().getTime() - getTaskTime.getTime()); + let waitMS = Math.max(0, task.getVisibilityTimeout() * 1000 - (new Date().getTime() - getTaskTime.getTime())); timeoutId = setTimeout(function() { isTimeout = true; timeoutId = undefined; @@ -1099,7 +1104,8 @@ function ackTask(ctx, res, task, ack) { }); } function receiveTaskSetTimeout(ctx, task, ack, outParams) { - let delay = 1.1 * task.getVisibilityTimeout() * 1000; + //add DownloadTimeout to upload results + let delay = task.getVisibilityTimeout() * 1000 + ms(cfgDownloadTimeout.wholeCycle); return setTimeout(function() { return co(function*() { outParams.isAck = true;