data: data ?? ({} as Data),
timestamp,
workerId: this.getWorkerInfo(workerNodeKey).id as number,
- id: randomUUID()
+ taskId: randomUUID()
}
- this.promiseResponseMap.set(task.id as string, {
+ this.promiseResponseMap.set(task.taskId as string, {
resolve,
reject,
workerNodeKey
if (message.ready != null) {
// Worker ready response received from worker
this.handleWorkerReadyResponse(message)
- } else if (message.id != null) {
+ } else if (message.taskId != null) {
// Task execution response received from worker
this.handleTaskExecutionResponse(message)
}
}
private handleTaskExecutionResponse (message: MessageValue<Response>): void {
- const promiseResponse = this.promiseResponseMap.get(message.id as string)
+ const promiseResponse = this.promiseResponseMap.get(
+ message.taskId as string
+ )
if (promiseResponse != null) {
if (message.taskError != null) {
this.emitter?.emit(PoolEvents.taskError, message.taskError)
}
const workerNodeKey = promiseResponse.workerNodeKey
this.afterTaskExecutionHook(workerNodeKey, message)
- this.promiseResponseMap.delete(message.id as string)
+ this.promiseResponseMap.delete(message.taskId as string)
if (
this.opts.enableTasksQueue === true &&
this.tasksQueueSize(workerNodeKey) > 0 &&
!this.isMain && message.checkActive
? this.startCheckActive()
: this.stopCheckActive()
- } else if (message.id != null && message.data != null) {
+ } else if (message.taskId != null && message.data != null) {
// Task message received
this.run(message)
} else if (message.kill === true) {
data: res,
taskPerformance,
workerId: this.id,
- id: task.id
+ taskId: task.taskId
})
} catch (e) {
const errorMessage = this.handleError(e as Error | string)
data: task.data
},
workerId: this.id,
- id: task.id
+ taskId: task.taskId
})
} finally {
this.updateLastTaskTimestamp()
data: res,
taskPerformance,
workerId: this.id,
- id: task.id
+ taskId: task.taskId
})
return null
})
data: task.data
},
workerId: this.id,
- id: task.id
+ taskId: task.taskId
})
})
.finally(() => {