MessageValue,
PromiseWorkerResponseWrapper
} from '../utility-types'
-import { EMPTY_FUNCTION, EMPTY_LITERAL } from '../utils'
-import { isKillBehavior, KillBehaviors } from '../worker/worker-options'
+import { EMPTY_FUNCTION } from '../utils'
+import { KillBehaviors, isKillBehavior } from '../worker/worker-options'
import type { PoolOptions } from './pool'
import { PoolEmitter } from './pool'
import type { IPoolInternal, TasksUsage } from './pool-internal'
import type { IPoolWorker } from './pool-worker'
import {
WorkerChoiceStrategies,
- WorkerChoiceStrategy
+ type WorkerChoiceStrategy
} from './selection-strategies/selection-strategies-types'
import { WorkerChoiceStrategyContext } from './selection-strategies/worker-choice-strategy-context'
const res = this.internalExecute(worker, this.nextMessageId)
this.checkAndEmitBusy()
this.sendToWorker(worker, {
- data: data ?? (EMPTY_LITERAL as Data),
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
+ data: data ?? ({} as Data),
id: this.nextMessageId
})
++this.nextMessageId
/** {@inheritDoc} */
public async destroy (): Promise<void> {
- await Promise.all(this.workers.map(worker => this.destroyWorker(worker)))
+ await Promise.all(
+ this.workers.map(async worker => {
+ await this.destroyWorker(worker)
+ })
+ )
}
/**
worker.on('error', this.opts.errorHandler ?? EMPTY_FUNCTION)
worker.on('online', this.opts.onlineHandler ?? EMPTY_FUNCTION)
worker.on('exit', this.opts.exitHandler ?? EMPTY_FUNCTION)
- worker.once('exit', () => this.removeWorker(worker))
+ worker.once('exit', () => {
+ this.removeWorker(worker)
+ })
this.workers.push(worker)