Limit retries based on maxRetryCount
How do set max retry count? I have a requirement that I need to do 3 reties before concluding the step as error.
That is a feature that still needs to be implemented. My thinking is that you should be able to specify a retry count and what action happens after that (terminate or suspend)?
You can also access the retry count from within your step
context.pointer.retryCount
Even I get the retryCount in step. How do I change error handling strategy of workflow from run method?
I can't force termination of workflow from step body.
yes, this feature is lacking at the moment
@vimalraj-a
Even I get the retryCount in step. How do I change error handling strategy of workflow from run method?
You can override the strategy by doing
context.step.errorBehavior = WorkflowErrorHandling.Terminate;
Your step could then look like
class FailingStep extends StepBody {
private retryLimit = 2;
async run(context: StepExecutionContext): Promise<ExecutionResult> {
if (context.pointer.retryCount >= this.retryLimit) {
console.log('retry limit reached');
context.step.errorBehavior = WorkflowErrorHandling.Terminate; // here we override the error handling strategy
throw new Error('This step has failed too many times : Terminating');
}
// try to do something that fails
throw new Error('This step failed');
}
}