Skip to content

Return errors in CodeExecutor class #14

Closed
@roerohan

Description

@roerohan

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);
}
});

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghacktoberfestHacktoberfest 2020

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions