`Invalid worker node tasks concurrency: ${tasksQueueOptions.concurrency} is a negative integer or zero`
)
}
- if (
- tasksQueueOptions?.queueMaxSize != null &&
- tasksQueueOptions?.size != null
- ) {
+ if (tasksQueueOptions?.queueMaxSize != null) {
throw new Error(
- 'Invalid tasks queue options: cannot specify both queueMaxSize and size'
+ 'Invalid tasks queue options: queueMaxSize is deprecated, please use size instead'
)
}
- if (tasksQueueOptions?.queueMaxSize != null) {
- tasksQueueOptions.size = tasksQueueOptions.queueMaxSize
- }
if (
tasksQueueOptions?.size != null &&
!Number.isSafeInteger(tasksQueueOptions.size)
) {
throw new TypeError(
- 'Invalid worker node tasks queue max size: must be an integer'
+ 'Invalid worker node tasks queue size: must be an integer'
)
}
if (tasksQueueOptions?.size != null && tasksQueueOptions.size <= 0) {
throw new RangeError(
- `Invalid worker node tasks queue max size: ${tasksQueueOptions.size} is a negative integer or zero`
+ `Invalid worker node tasks queue size: ${tasksQueueOptions.size} is a negative integer or zero`
)
}
}
}
private tasksStealingOnBackPressure (workerId: number): void {
+ if ((this.opts.tasksQueueOptions?.size as number) <= 1) {
+ return
+ }
const sourceWorkerNode =
this.workerNodes[this.getWorkerNodeKeyByWorkerId(workerId)]
const workerNodes = this.workerNodes
expect(() => pool.setTasksQueueOptions({ concurrency: 0.2 })).toThrowError(
new TypeError('Invalid worker node tasks concurrency: must be an integer')
)
+ expect(() => pool.setTasksQueueOptions({ queueMaxSize: 2 })).toThrowError(
+ new Error(
+ 'Invalid tasks queue options: queueMaxSize is deprecated, please use size instead'
+ )
+ )
expect(() => pool.setTasksQueueOptions({ size: 0 })).toThrowError(
new RangeError(
- 'Invalid worker node tasks queue max size: 0 is a negative integer or zero'
+ 'Invalid worker node tasks queue size: 0 is a negative integer or zero'
)
)
expect(() => pool.setTasksQueueOptions({ size: -1 })).toThrowError(
new RangeError(
- 'Invalid worker node tasks queue max size: -1 is a negative integer or zero'
+ 'Invalid worker node tasks queue size: -1 is a negative integer or zero'
)
)
expect(() => pool.setTasksQueueOptions({ size: 0.2 })).toThrowError(
- new TypeError(
- 'Invalid worker node tasks queue max size: must be an integer'
- )
+ new TypeError('Invalid worker node tasks queue size: must be an integer')
)
await pool.destroy()
})