workflow-es icon indicating copy to clipboard operation
workflow-es copied to clipboard

Async steps body

Open obender opened this issue 8 years ago • 6 comments

Hi, How to implement async step body... the system crashes when i add await to step body....

obender avatar Jan 24 '18 07:01 obender

Could you attach the problem code here?

danielgerlag avatar Jan 24 '18 15:01 danielgerlag

Hi,

I have successfully tested this

class HelloWorld extends workflow_es.StepBody {
    async run(context) {
        console.log("Hello World");
        await doSomethingAsync();
        return workflow_es.ExecutionResult.next();
    }
}

danielgerlag avatar Jan 27 '18 19:01 danielgerlag

@danielgerlag between steps, is a step will waiting for the previous step finished with async?

twilroad avatar Mar 29 '18 04:03 twilroad

yes it does, but if you call an async method or promise from within the step and don't await it, then it can't know about it

danielgerlag avatar Mar 31 '18 15:03 danielgerlag

so, it can not await for async method

twilroad avatar Apr 02 '18 02:04 twilroad

as you can see here:

https://github.com/danielgerlag/workflow-es/blob/master/core/src/services/workflow-executor.ts#L73

it does in fact await, but if you fail to await any nested async methods inside your step implementation, then it's your choice

danielgerlag avatar Apr 02 '18 02:04 danielgerlag