this.emitter.emit(PoolEvents.taskError, message.taskError)
}
promiseResponse.reject(
- `${message.taskError.message} on worker '${message.taskError.workerId}`
+ `${message.taskError.message} on worker '${message.taskError.workerId}'`
)
} else {
promiseResponse.resolve(message.data as Response)
*
* @defaultValue 1
*/
- concurrency?: number
+ readonly concurrency?: number
}
/**
/**
* Set measurement median.
*/
- median: boolean
+ readonly median: boolean
}
/**
/**
* Measurement to use for worker choice strategy.
*/
- measurement?: Measurement
+ readonly measurement?: Measurement
/**
* Runtime options.
*
* @defaultValue \{ median: false \}
*/
- runTime?: MeasurementOptions
+ readonly runTime?: MeasurementOptions
/**
* Wait time options.
*
* @defaultValue \{ median: false \}
*/
- waitTime?: MeasurementOptions
+ readonly waitTime?: MeasurementOptions
/**
* Event loop utilization options.
*
* @defaultValue \{ median: false \}
*/
- elu?: MeasurementOptions
+ readonly elu?: MeasurementOptions
/**
* Worker weights to use for weighted round robin worker selection strategy.
* Weight is the tasks maximum average or median runtime in milliseconds.
*
* @defaultValue Computed worker weights automatically given the CPU performance.
*/
- weights?: Record<number, number>
+ readonly weights?: Record<number, number>
}
/**
/**
* Tasks runtime requirements.
*/
- runTime: MeasurementStatisticsRequirements
+ readonly runTime: MeasurementStatisticsRequirements
/**
* Tasks wait time requirements.
*/
- waitTime: MeasurementStatisticsRequirements
+ readonly waitTime: MeasurementStatisticsRequirements
/**
* Tasks event loop utilization requirements.
*/
- elu: MeasurementStatisticsRequirements
+ readonly elu: MeasurementStatisticsRequirements
}
/**
/**
* Expects direct usage of dynamic worker.
*/
- useDynamicWorker: boolean
+ readonly useDynamicWorker: boolean
}
/**
/**
* Measurement history.
*/
- history: CircularArray<number>
+ readonly history: CircularArray<number>
}
/**
* @internal
*/
export interface EventLoopUtilizationMeasurementStatistics {
- idle: MeasurementStatistics
- active: MeasurementStatistics
+ readonly idle: MeasurementStatistics
+ readonly active: MeasurementStatistics
utilization: number
}
/**
* Worker id.
*/
- id: number | undefined
+ readonly id: number | undefined
/**
* Started flag.
*/
/**
* Tasks statistics.
*/
- tasks: TaskStatistics
+ readonly tasks: TaskStatistics
/**
* Tasks runtime statistics.
*/
- runTime: MeasurementStatistics
+ readonly runTime: MeasurementStatistics
/**
* Tasks wait time statistics.
*/
- waitTime: MeasurementStatistics
+ readonly waitTime: MeasurementStatistics
/**
* Tasks event loop utilization statistics.
*/
- elu: EventLoopUtilizationMeasurementStatistics
+ readonly elu: EventLoopUtilizationMeasurementStatistics
}
/**
/**
* Worker node worker info.
*/
- info: WorkerInfo
+ readonly info: WorkerInfo
/**
* Worker node worker usage statistics.
*/
/**
* Worker id.
*/
- workerId: number
+ readonly workerId: number
/**
* Error message.
*/
- message: string
+ readonly message: string
/**
* Data passed to the worker triggering the error.
*/
- data?: Data
+ readonly data?: Data
}
/**
/**
* Task performance timestamp.
*/
- timestamp: number
+ readonly timestamp: number
/**
* Task runtime.
*/
- runTime?: number
+ readonly runTime?: number
/**
* Task event loop utilization.
*/
- elu?: EventLoopUtilization
+ readonly elu?: EventLoopUtilization
}
/**
}
expect(inError).toBeDefined()
expect(typeof inError === 'string').toBe(true)
- expect(inError).toBe('Error Message from ClusterWorker')
- expect(taskError).toStrictEqual({
- message: 'Error Message from ClusterWorker',
- data
- })
+ expect(inError).toContain('Error Message from ClusterWorker on worker')
+ expect(taskError.data).toStrictEqual(data)
expect(
errorPool.workerNodes.some(
workerNode => workerNode.usage.tasks.failed === 1
}
expect(inError).toBeDefined()
expect(typeof inError === 'string').toBe(true)
- expect(inError).toBe('Error Message from ClusterWorker:async')
- expect(taskError).toStrictEqual({
- message: 'Error Message from ClusterWorker:async',
- data
- })
+ expect(inError).toContain(
+ 'Error Message from ClusterWorker:async on worker'
+ )
+ expect(taskError.data).toStrictEqual(data)
expect(
asyncErrorPool.workerNodes.some(
workerNode => workerNode.usage.tasks.failed === 1
expect(inError).toBeInstanceOf(Error)
expect(inError.message).toBeDefined()
expect(typeof inError.message === 'string').toBe(true)
- expect(inError.message).toBe('Error Message from ThreadWorker')
- expect(taskError).toStrictEqual({
- message: new Error('Error Message from ThreadWorker'),
- data
- })
+ expect(inError.message).toContain(
+ 'Error Message from ThreadWorker on worker'
+ )
+ expect(taskError.data).toStrictEqual(data)
expect(
errorPool.workerNodes.some(
workerNode => workerNode.usage.tasks.failed === 1
expect(inError).toBeInstanceOf(Error)
expect(inError.message).toBeDefined()
expect(typeof inError.message === 'string').toBe(true)
- expect(inError.message).toBe('Error Message from ThreadWorker:async')
- expect(taskError).toStrictEqual({
- message: new Error('Error Message from ThreadWorker:async'),
- data
- })
+ expect(inError.message).toContain(
+ 'Error Message from ThreadWorker:async on worker'
+ )
+ expect(taskError.data).toStrictEqual(data)
expect(
asyncErrorPool.workerNodes.some(
workerNode => workerNode.usage.tasks.failed === 1