in workflow step if we want to return

in workflow step if we want to return not just from step also from workflow successfully what can we do, do you have any idea ? I mean is there any equivalent form of non retryable error
9 Replies
avenceslau
avenceslau•2d ago
I don' t think I understand, can you please re-explain 😅
orangesbracelet
orangesbraceletOP•2d ago
In the code if isCompleted true I want to exit from workflow but as I cant, I return as variable and then check that variable then exit
No description
orangesbracelet
orangesbraceletOP•2d ago
I ask is there any syntax like non retryable error to exit from workflow inside step
avenceslau
avenceslau•2d ago
Not currently no. Just to be sure, what you mean is that there may be more steps after that one but you don't want to run them, is that it?
orangesbracelet
orangesbraceletOP•2d ago
yes if completed I dont want to run them
avenceslau
avenceslau•2d ago
You can have the steps inside of the if.
const isCompleted = await step.do(async () => {
// do some logic
return true
})

if(!isCompleted) {
await step.do(async () => {
// run fallback logic
})

// we can run more steps here
}
const isCompleted = await step.do(async () => {
// do some logic
return true
})

if(!isCompleted) {
await step.do(async () => {
// run fallback logic
})

// we can run more steps here
}
Not sure if this is similar enough to what you want to do TLDR: we don't expose a way to return early (from inside a step) but you can have parts of your workflow that run conditionally
orangesbracelet
orangesbraceletOP•2d ago
then you dont suggest to return early in workflows like that, instead running steps conditionally right ?
No description
avenceslau
avenceslau•2d ago
I think that there is no harm done to be honest, if I think of a reason why you shouldn't I will get back to you 🙂
orangesbracelet
orangesbraceletOP•2d ago
thx too much ur my savior 🙂

Did you find this page helpful?