protected checkDynamicPoolSize (min: number, max: number): void {
if (this.type === PoolTypes.dynamic) {
- if (!Number.isSafeInteger(max)) {
+ if (max == null) {
+ throw new Error(
+ 'Cannot instantiate a dynamic pool without specifying the maximum pool size'
+ )
+ } else if (!Number.isSafeInteger(max)) {
throw new TypeError(
'Cannot instantiate a dynamic pool with a non safe integer maximum pool size'
)
workerInfo.ready &&
workerNode.usage.tasks.queued === 0
) {
- if (workerNode.usage.tasks.executing === 0) {
+ if (
+ this.workerNodes[workerNodeId].usage.tasks.executing <
+ (this.opts.tasksQueueOptions?.concurrency as number)
+ ) {
executeTask = true
}
targetWorkerNodeKey = workerNodeId
})
it('Verify that dynamic pool sizing is checked', () => {
+ expect(
+ () =>
+ new DynamicClusterPool(
+ 1,
+ undefined,
+ './tests/worker-files/cluster/testWorker.js'
+ )
+ ).toThrowError(
+ new TypeError(
+ 'Cannot instantiate a dynamic pool without specifying the maximum pool size'
+ )
+ )
expect(
() =>
new DynamicThreadPool(
new DynamicClusterPool(
0,
0.5,
- './tests/worker-files/thread/testWorker.js'
+ './tests/worker-files/cluster/testWorker.js'
)
).toThrowError(
new TypeError(
new DynamicClusterPool(
1,
1,
- './tests/worker-files/thread/testWorker.js'
+ './tests/worker-files/cluster/testWorker.js'
)
).toThrowError(
new RangeError(