) {
reject(
new Error(
- `Task function operation ${
+ `Task function operation '${
message.taskFunctionOperation as string
- } failed on worker ${message.workerId}`
+ }' failed on worker ${message.workerId} with error: '${
+ message.workerError?.message as string
+ }'`
)
)
}
message => message.taskFunctionOperationStatus === false
)
) {
+ const errorResponse = responsesReceived.find(
+ response => response.taskFunctionOperationStatus === false
+ )
reject(
new Error(
- `Task function operation ${
+ `Task function operation '${
message.taskFunctionOperation as string
- } failed on worker ${message.workerId as number}`
+ }' failed on worker ${
+ errorResponse?.workerId as number
+ } with error: '${
+ errorResponse?.workerError?.message as string
+ }'`
)
)
}
'./tests/worker-files/thread/testMultipleTaskFunctionsWorker.js'
)
await waitPoolEvents(dynamicThreadPool, PoolEvents.ready, 1)
+ await expect(
+ dynamicThreadPool.setDefaultTaskFunction(0)
+ ).rejects.toThrowError(
+ new Error(
+ "Task function operation 'default' failed on worker 31 with error: 'TypeError: name parameter is not a string'"
+ )
+ )
+ await expect(
+ dynamicThreadPool.setDefaultTaskFunction(DEFAULT_TASK_NAME)
+ ).rejects.toThrowError(
+ new Error(
+ "Task function operation 'default' failed on worker 31 with error: 'Error: Cannot set the default task function reserved name as the default task function'"
+ )
+ )
+ await expect(
+ dynamicThreadPool.setDefaultTaskFunction('unknown')
+ ).rejects.toThrowError(
+ new Error(
+ "Task function operation 'default' failed on worker 31 with error: 'Error: Cannot set the default task function to a non-existing task function'"
+ )
+ )
expect(dynamicThreadPool.listTaskFunctionNames()).toStrictEqual([
DEFAULT_TASK_NAME,
'jsonIntegerSerialization',