#Using separate task vs using retry

1 messages · Page 1 of 1 (latest)

rapid sonnet
#

In Inngest, any retriable block of code is wrapped inside a step.run block, each step can pass it's result to the next step.

const result = await step.run("get-api-data", async () => {
  // Steps should return data used in other steps
  return fetch("...").json();
});

In Trigger, It seems I can achieve the same either by making each steps a separate task and triggerAndWait them in a parent task or using the retry.onThrow function.

Is there a rule of thumb for when to use one over the other?

For example, I know if I need batchTrigger, I need to create a separate child Task then.

ripe galleon
#

It's a good question.

I tend to only break things into tasks if I want to re-use that code in multiple places, I want to call it in parallel (batchTrigger), or I need idempotency (https://trigger.dev/docs/v3/idempotency).

If I don't need any of those then I'll use retry.onThrow or even just left things throw errors and have the task auto-retry

Trigger.dev

Welcome to the Trigger.dev v3 documentation.

rapid sonnet
#

Oho! awesome, I forgot letting the whole task retry is an option.