/**
* Handler id of the `activeInterval` worker activity check.
*/
- // eslint-disable-next-line no-undef
protected activeInterval?: NodeJS.Timeout
/**
switch (taskFunctionOperation) {
case 'add':
response = this.addTaskFunction(taskFunctionProperties.name, {
- // eslint-disable-next-line no-new-func
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
taskFunction: new Function(
- `return ${taskFunction}`
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ `return ${taskFunction!}`
)() as TaskFunction<Data, Response>,
...(taskFunctionProperties.priority != null && {
priority: taskFunctionProperties.priority,
response = { status: false, error: new Error('Unknown task operation') }
break
}
+ const { status, error } = response
this.sendToMainWorker({
taskFunctionOperation,
- taskFunctionOperationStatus: response.status,
+ taskFunctionOperationStatus: status,
taskFunctionProperties,
- ...(!response.status &&
- response.error != null && {
+ ...(!status &&
+ error != null && {
workerError: {
name: taskFunctionProperties.name,
- message: this.handleError(response.error as Error | string),
+ message: this.handleError(error as Error | string),
},
}),
})
protected handleKillMessage (message: MessageValue<Data>): void {
this.stopCheckActive()
if (isAsyncFunction(this.opts.killHandler)) {
- ;(this.opts.killHandler() as Promise<void>)
+ ;(this.opts.killHandler as () => Promise<void>)()
.then(() => {
this.sendToMainWorker({ kill: 'success' })
return undefined
})
} else {
try {
- this.opts.killHandler?.()
+ ;(this.opts.killHandler as (() => void) | undefined)?.()
this.sendToMainWorker({ kill: 'success' })
} catch {
this.sendToMainWorker({ kill: 'failure' })
throw new Error('Message worker id is not set')
} else if (message.workerId !== this.id) {
throw new Error(
- `Message worker id ${message.workerId} does not match the worker id ${this.id}`
+ `Message worker id ${message.workerId.toString()} does not match the worker id ${this.id.toString()}`
)
}
}
workerError: {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
name: name!,
- message: `Task function '${name}' not found`,
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ message: `Task function '${name!}' not found`,
data,
},
taskId,