inngest-js icon indicating copy to clipboard operation
inngest-js copied to clipboard

Add an `onError` handler to `run` which is called when a step permanently fails

Open tonyhb opened this issue 2 years ago • 0 comments

It would be good to allow users to specify cleanup code for individual steps of a function.

An example:

tools.run(
  "Something fragile",
  () => {
    // This always fails
    throw new Error("noooo!");
  },
  {
    onFail: (error: Error) => {
      // This runs after the step has been
    }
  },
});

As @jpwilliams mentioned, this could also be done via try/catch, etc. - the implementation is an open question :)

tonyhb avatar Nov 09 '22 17:11 tonyhb