Skip to content

Catch unhandled promise error #19

@GiovaniGuizzo

Description

@GiovaniGuizzo

Right now, this code in the ExecutorManager is not dealing with unknown errors or cancels:

    try {
      logger("Executor Manager").debug(`Running job ${job.id} in queue ${queueConfig.name}`);
      const result = await this.runnerPool.run(job, signal);
      isRunning = false;
      logger("Executor Manager").debug(`Job ${job.id} completed with result: ${JSON.stringify(result)}`);
      const transition = JobTransitionFactory.create(result);
      await JobTransitioner.apply(this.backend, job, transition);
    } catch (error: unknown) {
      isRunning = false;
      const err = error as Error;
      if (err.message === "The task has been aborted") {
        logger("Executor Manager").debug(`Job ${job.id} was canceled`);
      } else {
        logger("Executor Manager").error(`Error executing job ${job.id}: ${err.message}`);
        throw error;
      }
    } finally {
      isRunning = false;
      this.activeByQueue[queueConfig.name].delete(job.id);
      this.activeJobs.delete(job.id);
    }

Sometimes, if there is an unhandled error in a promise (that does not reject), the perform method from a job does not catch it and does not create a retry transition.

We need to:

  1. Catch unhandled errors in perform and return the correct transition
  2. Deal with unknown errors in the executor-manager
  3. Deal with cancellation on executor-manager

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions