Reschedule a run (from inside the run)

If there’s an external service that you need to check to determine if you continue the run, it would be useful to have a way of rescheduling the run from inside that run.

export const myTask = task({
  id: "myTask",
  run: async (payload) => {
    const isReady = await externalService.isReady();
    if (!isReady) {
      //for with a delay
      await reschedule.for({ minutes: 15 });
      //or until with a date
      // await reschedule.until(new Date("2022-01-01T00:00:00Z"));
    }
    
    //do stuff
  },
});

It would end the attempt and schedule the run for the specified date. When it re-runs it would have a new attempt but wouldn’t count as a failed attempt. So you could have this happen many times and it wouldn’t impact error retrying.

Upvoters
Status

In Review

Board

💡 Feature Request

Date

Over 1 year ago

Author

mattaitken

Subscribe to post

Get notified by email when there are changes.