serverless-step-functions-local
serverless-step-functions-local copied to clipboard
Local Retry mechanism when throwing errors
When a JavaScript error is thrown within a Task state that has a retry it ends the node server with an error. Is there any way to avoid this, to replicate error handling on AWS locally?
My code is as follows:
serverless.yml
FinalState:
Type: Task
Resource:
Fn::GetAtt: [world, Arn]
Retry:
- ErrorEquals: ["States.ALL"]
IntervalSeconds: 1
MaxAttempts: 5
BackoffRate: 2
world function in handler:
module.exports.world = async event => {
const num = Math.floor(Math.random() * 2) + 1
if (num === 1) {
throw new Error('Failed')
}
return { message: 'Success', event }
}
(the function just basically generates a random number between one and two, if the number is 1 then it fails, so this function should fail 50% of the time).
I'm not sure to be honest. I've not used this for something like 2 years and I don't really remember how step function error handling works.
Happy to look over any PR if you wanna submit one. 😛
Hey @codetheweb , curious about which package are you using now to run Step Functions in the local environment. Would you mind sharing the info?
Thanks!
Well, I could rant about serverless not living up to the hype.
But I'll just leave it at that I don't use step functions (or really any other niche AWS products) anymore. 😉