- worker.on('message', (msg) => {
- (async () => {
- await this.messageHandler(msg);
- })().catch(() => {
- /* This is intentional */
- });
- });
- worker.on('error', () => {
- /* This is intentional */
- });
+ worker.on(
+ 'message',
+ (
+ this.workerOptions?.messageHandler ??
+ (() => {
+ /* This is intentional */
+ })
+ ).bind(this) as MessageHandler<Worker>
+ );
+ worker.on('error', WorkerUtils.defaultErrorHandler.bind(this) as (err: Error) => void);