Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
workerError: {
name: taskFunctionName as string,
message: this.handleError(response.error as Error | string)
workerError: {
name: taskFunctionName as string,
message: this.handleError(response.error as Error | string)
if (isAsyncFunction(this.opts.killHandler)) {
(this.opts.killHandler?.() as Promise<void>)
.then(() => {
if (isAsyncFunction(this.opts.killHandler)) {
(this.opts.killHandler?.() as Promise<void>)
.then(() => {
- this.sendToMainWorker({ kill: 'success', workerId: this.id })
+ this.sendToMainWorker({ kill: 'success' })
return null
})
.catch(() => {
return null
})
.catch(() => {
- this.sendToMainWorker({ kill: 'failure', workerId: this.id })
+ this.sendToMainWorker({ kill: 'failure' })
})
.finally(() => {
this.emitDestroy()
})
.finally(() => {
this.emitDestroy()
try {
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
this.opts.killHandler?.() as void
try {
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
this.opts.killHandler?.() as void
- this.sendToMainWorker({ kill: 'success', workerId: this.id })
+ this.sendToMainWorker({ kill: 'success' })
- this.sendToMainWorker({ kill: 'failure', workerId: this.id })
+ this.sendToMainWorker({ kill: 'failure' })
} finally {
this.emitDestroy()
}
} finally {
this.emitDestroy()
}
performance.now() - this.lastTaskTimestamp >
(this.opts.maxInactiveTime ?? DEFAULT_MAX_INACTIVE_TIME)
) {
performance.now() - this.lastTaskTimestamp >
(this.opts.maxInactiveTime ?? DEFAULT_MAX_INACTIVE_TIME)
) {
- this.sendToMainWorker({ kill: this.opts.killBehavior, workerId: this.id })
+ this.sendToMainWorker({ kill: this.opts.killBehavior })
*/
protected sendTaskFunctionNamesToMainWorker (): void {
this.sendToMainWorker({
*/
protected sendTaskFunctionNamesToMainWorker (): void {
this.sendToMainWorker({
- taskFunctionNames: this.listTaskFunctionNames(),
- workerId: this.id
+ taskFunctionNames: this.listTaskFunctionNames()
message: `Task function '${name as string}' not found`,
data
},
message: `Task function '${name as string}' not found`,
data
},
this.sendToMainWorker({
data: res,
taskPerformance,
this.sendToMainWorker({
data: res,
taskPerformance,
taskId
})
} catch (error) {
taskId
})
} catch (error) {
message: this.handleError(error as Error | string),
data
},
message: this.handleError(error as Error | string),
data
},
this.sendToMainWorker({
data: res,
taskPerformance,
this.sendToMainWorker({
data: res,
taskPerformance,
message: this.handleError(error as Error | string),
data
},
message: this.handleError(error as Error | string),
data
},
this.getMainWorker().on('message', this.messageListener.bind(this))
this.sendToMainWorker({
ready: true,
this.getMainWorker().on('message', this.messageListener.bind(this))
this.sendToMainWorker({
ready: true,
- taskFunctionNames: this.listTaskFunctionNames(),
- workerId: this.id
+ taskFunctionNames: this.listTaskFunctionNames()
})
} catch {
this.sendToMainWorker({
ready: false,
})
} catch {
this.sendToMainWorker({
ready: false,
- taskFunctionNames: this.listTaskFunctionNames(),
- workerId: this.id
+ taskFunctionNames: this.listTaskFunctionNames()
/** @inheritDoc */
protected sendToMainWorker (message: MessageValue<Response>): void {
/** @inheritDoc */
protected sendToMainWorker (message: MessageValue<Response>): void {
- this.getMainWorker().send(message)
+ this.getMainWorker().send({ ...message, workerId: this.id })
this.port.on('message', this.messageListener.bind(this))
this.sendToMainWorker({
ready: true,
this.port.on('message', this.messageListener.bind(this))
this.sendToMainWorker({
ready: true,
- taskFunctionNames: this.listTaskFunctionNames(),
- workerId: this.id
+ taskFunctionNames: this.listTaskFunctionNames()
})
} catch {
this.sendToMainWorker({
ready: false,
})
} catch {
this.sendToMainWorker({
ready: false,
- taskFunctionNames: this.listTaskFunctionNames(),
- workerId: this.id
+ taskFunctionNames: this.listTaskFunctionNames()
/** @inheritDoc */
protected sendToMainWorker (message: MessageValue<Response>): void {
/** @inheritDoc */
protected sendToMainWorker (message: MessageValue<Response>): void {
- this.port.postMessage(message)
+ this.port.postMessage({ ...message, workerId: this.id })