ozone-typescript-client
Advanced tools
Comparing version 6.1.6 to 6.1.7
@@ -17,8 +17,8 @@ import { UUID, TaskExecution } from 'ozone-type'; | ||
onProgress?: (taskExecution: TaskExecution) => void; | ||
private subTaskinterval?; | ||
private pollInterval; | ||
private interval?; | ||
private timeout?; | ||
private subTimeout?; | ||
private rejectPromise?; | ||
stopWaiting(): void; | ||
_clearPullInterval(): void; | ||
_clearPullTimeout(): void; | ||
private executeCallback; | ||
@@ -25,0 +25,0 @@ readonly waitResult: Promise<T | undefined>; |
@@ -20,3 +20,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
const waitingTime = 1000; // ms | ||
const waitingTime = 10000; // ms | ||
export class TaskHandlerImpl { | ||
@@ -31,3 +31,3 @@ constructor(taskId, client, baseUrl, options) { | ||
stopWaiting() { | ||
this._clearPullInterval(); | ||
this._clearPullTimeout(); | ||
const stopWaitingErrorMessage = { error: 'Wait for task canceled' }; | ||
@@ -37,5 +37,5 @@ this.executeCallback(this.onError, stopWaitingErrorMessage); | ||
} | ||
_clearPullInterval() { | ||
clearInterval(this.subTaskinterval); | ||
clearInterval(this.interval); | ||
_clearPullTimeout() { | ||
clearTimeout(this.timeout); | ||
clearTimeout(this.subTimeout); | ||
} | ||
@@ -49,18 +49,24 @@ executeCallback(callback, param) { | ||
return (new Promise((resolve, reject) => { | ||
this.subTaskinterval = window.setInterval(() => { | ||
this._awaitTask(asyncTasksGroupId) | ||
.then((data) => { | ||
if (data.stepsCount === data.stepsDone) { | ||
this._clearPullInterval(); | ||
resolve(); | ||
} | ||
else if (data.hasErrors) { | ||
reject('One of the processing sub tasks as an error'); | ||
} | ||
}) | ||
.catch((error) => { | ||
this._clearPullInterval(); | ||
reject(error); | ||
}); | ||
}, this.pollInterval); | ||
const wait = () => { | ||
this.subTimeout = window.setTimeout(() => { | ||
this._awaitTask(asyncTasksGroupId) | ||
.then((data) => { | ||
if (data.stepsCount !== data.stepsDone) { | ||
wait(); | ||
} | ||
else if (data.hasErrors) { | ||
reject('One of the processing sub tasks as an error'); | ||
} | ||
else if (data.stepsDone === data.stepsCount) { | ||
this._clearPullTimeout(); | ||
resolve(); | ||
} | ||
}) | ||
.catch((error) => { | ||
this._clearPullTimeout(); | ||
reject(error); | ||
}); | ||
}, this.pollInterval); | ||
}; | ||
wait(); | ||
})); | ||
@@ -72,25 +78,31 @@ } | ||
this.rejectPromise = reject; | ||
this.interval = window.setInterval(() => { | ||
this._awaitTask(taskId) | ||
.then((data) => { | ||
if (data && data.taskExecutions) { | ||
const taskExecution = data.taskExecutions[taskId]; | ||
this.executeCallback(this.onProgress, taskExecution); | ||
if (data.hasErrors) { | ||
this.executeCallback(this.onError, taskExecution); | ||
clearInterval(this.interval); | ||
reject(Error(taskExecution.error || 'Error in ozone task')); | ||
const wait = () => { | ||
this.timeout = window.setTimeout(() => { | ||
this._awaitTask(taskId) | ||
.then((data) => { | ||
if (data && data.taskExecutions) { | ||
const taskExecution = data.taskExecutions[taskId]; | ||
this.executeCallback(this.onProgress, taskExecution); | ||
if (data.hasErrors) { | ||
this.executeCallback(this.onError, taskExecution); | ||
clearTimeout(this.timeout); | ||
reject(Error(taskExecution.error || 'Error in ozone task')); | ||
} | ||
else if (data.stepsDone === data.stepsCount) { | ||
this._clearPullTimeout(); | ||
primaryTaskResult = taskExecution; | ||
resolve(taskExecution); | ||
} | ||
else { | ||
wait(); | ||
} | ||
} | ||
else if (taskExecution.completed) { | ||
this._clearPullInterval(); | ||
primaryTaskResult = taskExecution; | ||
resolve(taskExecution); | ||
} | ||
} | ||
}) | ||
.catch((error) => { | ||
clearInterval(this.interval); | ||
reject(error); | ||
}); | ||
}, this.pollInterval); | ||
}) | ||
.catch((error) => { | ||
clearTimeout(this.timeout); | ||
reject(error); | ||
}); | ||
}, this.pollInterval); | ||
}; | ||
wait(); | ||
})) | ||
@@ -97,0 +109,0 @@ .then((taskResult) => { |
{ | ||
"name": "ozone-typescript-client", | ||
"version": "6.1.6", | ||
"version": "6.1.7", | ||
"description": "", | ||
@@ -40,3 +40,3 @@ "main": "dist/src/index.js", | ||
}, | ||
"gitHead": "3478c480fcd91c4c1c29db76ded3cbfc47621441" | ||
"gitHead": "b8447395a9e9d7f0dc7474fba8658bfdad6c78a9" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
477461
5209