Wait for prior Element Action to complete

The ability to chain multiple element actions together that run sequentially in order is great! The ability to use the result of the prior action through the $steps object is also powerful.

However, in instances where the actions are asynchronous, subsequent actions kick off immediately.

  • In some cases, this is desired because you don’t care about the result of the prior action.
  • In other cases, the subsequent action may be dependent on the prior action (e.g. updating a DB table, only if the prior action succeeded). In these instances, when the prior action is async, the $steps object is obviously not yet set because the promise is still pending meaning the function hasn’t returned.

When configuring actions in the Studio UI it would be great to be able to force waiting for the prior action to return/complete before the next action is run.

Currently working around this by adding a boolean action argument in the component registration that controls a wrapper function in the component logic and chooses whether to execute the actual target sync vs async. It feels common enough to be a core feature and would save a tonne of development time.

2 Likes

It’s a great idea, thank you. We’ve opened a feature request for this.

1 Like

Hi @ryan_mouritz, I checked with the team, and I believe that async element actions should always be awaited before subsequent actions. Your element action needs to make sure to return the Promise to await.

If you’re finding that your element action is not being awaited, could you share the code for your element action?

1 Like