Are RunActions() run asyncronhously via automations?

I have a button containing RunActions() that is pressed by an automation a certain time (and it’s taking action as me, not as the automation bot).

The button has nested RunActions(), something like:

RunActions(
ModifyRows(1),
ForEach(List,
RunActions(
SendEmail(),
_delay(_noop(), 5000),
ModifyRows(2)
)),
ModifyRows(3)
)

When the button is pressed manually by me, the RunActions() are all run syncronously one after the other, and I can see this happening in real time because of the various ModifyRows() and SendEmail(), and I can see them happening one after the other.

ie. ModifyRows(3) doesn’t occur until after the email is sent and ModifyRows(2) has completed.

But when the button is triggered by an automation (and the automation is only pressing the button and nothing else), I dont see any changes in the Coda UI until after the automation has completed, and then it appears that the RunActions() all occur at the same time.

So it seems that the button processing has occured in the background, before being updated in the Coda UI.

The ModifyRows(2) is writing a Now() value to a field, and these are all showing the exact same time when triggered by an automation, but different times when the button is pressed manually - about 5 seconds apart, due to the delay().

But the emails are being sent 5 seconds apart even when the automation has pressed the button, so the automation is not ignoring the delay().

Does anyone have any insight as to if RunActions() always run synchronously, or sometimes asynchronously, and do they run differently if triggered by an automation or not?

Thanks!

I seem to recall that the Now() formula behaves differently when an automation is running.
The automation runs on the Coda server and the Now() function returns the time that the automation started. So this may explain why it looks like the actions all ran at sane at the same time.

My own experience with nested RunActions() in automations is that they run sequentially.

You may need to devise an alternative test that does not depend on Now() to record the sequence of actions. Instead use an action that pumps a counter with SetControlValue(MyCounter,MyCounter+1) and record that value to see if the actions ran serially or in parallel.

@Paul_Danyliuk may have better advice to give on this?

Respect
Max

Also from my tests, _Delay() does not work when invoked by automations

Actions always run sequentially. There’s no concurrency in Coda.

That said, there’s a difference in how actions are run in the browser (i.e. triggered by you — including the ‘Test automation’ button) and on the backend.

First of all, no matter if it’s ‘run by you’ or ‘by automation bot’, it’s technically always the automation bot :slight_smile: ‘run by you’ only means it will use your personal connections for packs, but IIRC User() still would return Automation Bot or be blank.

Secondly — and that’s why you’re seeing all changes applied at once — is that on the backend, the automation bot runner loads the doc to perform its work but unlike the browser, it doesn’t open a WebSocket to sync the changes in real time (I’m not 100% confident it’s true but I assume so, and usually my assumptions about Coda are true, CC @alexdeneui). So the automation collects all the ops (individual little edits) that have to be done on the doc, and commits those all at once to the operations queue once the automation is over. Maybe it doesn’t skip the _Delay() — you just never see it. Coda then sees that in your browser there’s a bunch of operations that weren’t applied locally, and replays them all at once — similarly to how the doc updates after you go offline and then reconnect to the internet.

And thirdly, Now() is pretty unreliable in automations in general. To the best of my knowledge, it doesn’t use the real time clock value, but the timestamp of the last doc modification. It’s actually even worse than using Step 1 Result, because the result of Now() may be hours, days, weeks old (if the doc was never opened in that time) but Step 1 Result always returns the time of automation start in timed automations.

9 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.