Custom Auto-retry timings?

Is there a way to set custom timings for step auto-retry?
Speed is valuable in my worfkflows, so I don’t really want my steps to stop for a few minutes before trying again.
I would rather prefer 2-5-10 seconds pauses between retries, but it’s just my use case.

Hi @nykyta.yasynskyi,

Yes, you can set custom timings for step auto-retry in your Pipedream workflows. You can use the $.flow.rerun() method to set a custom delay between retries. Here’s an example of how you can set custom timings for retries:

export default defineComponent({
  async run({ $ }) {
    const MAX_RETRIES = 3;
    const { run } = $.context;

    if (run.runs === 1) {
      $.flow.rerun(2000, null, MAX_RETRIES); // 2 seconds delay
    } else if (run.runs === 2) {
      $.flow.rerun(5000, null, MAX_RETRIES); // 5 seconds delay
    } else if (run.runs === 3) {
      $.flow.rerun(10000, null, MAX_RETRIES); // 10 seconds delay
    } else if (run.runs === MAX_RETRIES + 1) {
      throw new Error("Max retries exceeded");

In this example, the step will retry with a 2-second delay on the first retry, a 5-second delay on the second retry, and a 10-second delay on the third retry. If the maximum number of retries is exceeded, an error will be thrown.
I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double check my answers and code! Learn how to build your own.

Should I put it after my main code or before in async run function?