mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 19:14:16 +00:00
format
This commit is contained in:
parent
2731fd7b4e
commit
79b8ecc98f
@ -21,7 +21,9 @@ export default class TasksQueue extends Core {
|
|||||||
|
|
||||||
processTasks() {
|
processTasks() {
|
||||||
if (this.runningTasksIds.length >= TasksQueue.maxRunningTasks ?? 1) {
|
if (this.runningTasksIds.length >= TasksQueue.maxRunningTasks ?? 1) {
|
||||||
this.console.log("We are already running the maximum number of tasks")
|
this.console.log(
|
||||||
|
"We are already running the maximum number of tasks",
|
||||||
|
)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,17 +49,20 @@ export default class TasksQueue extends Core {
|
|||||||
// add the task to the running tasks array
|
// add the task to the running tasks array
|
||||||
this.runningTasksIds.push(task.id)
|
this.runningTasksIds.push(task.id)
|
||||||
|
|
||||||
const taskResult = await task.fn()
|
const taskResult = await task.fn().catch((error) => {
|
||||||
.catch((error) => {
|
|
||||||
// delete the task from the running tasks array
|
// delete the task from the running tasks array
|
||||||
this.runningTasksIds = this.runningTasksIds.filter((runningTaskId) => runningTaskId !== task.id)
|
this.runningTasksIds = this.runningTasksIds.filter(
|
||||||
|
(runningTaskId) => runningTaskId !== task.id,
|
||||||
|
)
|
||||||
|
|
||||||
// propagate the error through an exception
|
// propagate the error through an exception
|
||||||
throw error
|
throw error
|
||||||
})
|
})
|
||||||
|
|
||||||
// delete the task from the running tasks array
|
// delete the task from the running tasks array
|
||||||
this.runningTasksIds = this.runningTasksIds.filter((runningTaskId) => runningTaskId !== task.id)
|
this.runningTasksIds = this.runningTasksIds.filter(
|
||||||
|
(runningTaskId) => runningTaskId !== task.id,
|
||||||
|
)
|
||||||
|
|
||||||
return taskResult
|
return taskResult
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user