Return errors in CodeExecutor class
Errors (if any) thrown from the by this.work() are not caught/handled in Worker.ts.
|
start() { |
|
this.queue.process(async (job, done) => { |
|
logger.info(`Received: ${job.data.id}`); |
|
const result = await this.work(job.data); |
|
|
|
logger.debug(JSON.stringify(result)); |
|
done(null, result); |
|
}); |
|
} |
The goal is to reject the promise in this.queue.on('global:completed') in the CodeExecutor class if the Worker ran into an error.
|
this.queue.on('global:completed', (_job: Bull.Job, result: string) => { |
|
const { id } = <Result>JSON.parse(result); |
|
|
|
logger.debug(`Running on complete for id: ${id}`); |
|
|
|
const currentJob = this.jobs.get(id); |
|
if (currentJob) { |
|
currentJob.resolve(result); |
|
this.jobs.delete(id); |
|
} |
|
}); |
Return errors in CodeExecutor class
Errors (if any) thrown from the by
this.work()are not caught/handled inWorker.ts.code-executor/src/Worker.ts
Lines 50 to 58 in b69766f
The goal is to reject the promise in
this.queue.on('global:completed')in theCodeExecutorclass if the Worker ran into an error.code-executor/src/CodeExecutor.ts
Lines 17 to 27 in b69766f