Schedule API Workflow Action Erroneously Reports Completion, Return Value is Always Null String

I’ve logged a bug report about this, #4458. Discussion in another couple of threads and troubleshooting another issue (about the “Leave Site?” dialog – which at times appears to be a “bug”, but actually is not), I discovered what appears to be an actual bug that – based on past discussions – has tripped up more than a few folks.

A short-ish summary of the problem with the Schedule API Workflow action and how it misbehaves is as follows:

There is a bug in the workflow action “Schedule API Workflow”. This action appears to have a return value and so it should behave like other actions with that feature. However, it seems that Schedule API Workflow instantaneously reports that it has completed (even though it has not, as can be demonstrated in a simple example page I’ve supplied to Bubble) and returns a null string as its “returned value.”

This can mess up the timing of downstream workflow actions. Since the Schedule API Workflow step erroneously reports completion, downstream steps that wait for it to report its completion will execute anyway (they don’t know any better).

More detail:

This action appears to have a return value (of type text) and so it seems that one should be able to ensure that workflows following Schedule API Workflow (“SAPIW”) only execute after the scheduling is complete (by examining its return value).

However, SAPIW does not report a return value after it completes, nor does it indicate completion when it has truly completed scheduling the requested API Workflow.

Instead, it seems to report to the workflow that its return value is available immediately. And its return value is always a null string.

This can cause many problems, including the one described here (which is how I discovered this bug): How to prevent browser message "Leaving site? Changes you made may not be saved."? and here: How to prevent browser message "Leaving site? Changes you made may not be saved."?

Bubble pushed an update today to fix this bug, and I can confirm that this now works properly. Schedule API Workflow now reports its value at the correct time.

Note that this may have some performance impacts now that it’s fixed. There are cases where you might schedule an API workflow, but (in the meantime) rely on values the API workflow that may change based on the workflow’s actions. If those actions are downstream of the Schedule API workflow step, they will now not execute until the workflow has been scheduled. (This is usually desirable, but isn’t always.)

If, like me, you sometimes just kick off an API workflow regardless of whether you care if the values change or not, this may cause a little performance degradation if that step appears upstream of the values you’re fine with being temporarily out-of-date. The solution is to parallelize things by moving the Schedule API Workflow step out of the workflow in question and into its own workflow that triggers on the same condition.

(It’s very hard for me to explain why you might do this, but an example is that when I load my Calendar Widgets or Booking Widgets, I load them with existing database values. I simultaneously kick of a workflow that goes and checks if external synced calendars have changed. This happens quite fast, so I do not choose to delay loading of the “existing” data, even though it may be mildly out of date. I had to move the “update” schedule API workflow action to its own Workflow square in a few cases where I did not desire to wait for scheduling to be confirmed (this can take a noticeable amount of time).

(As far as I can tell, Schedule API Workflow has been working improperly for as long as I’ve had such steps in deployment. The fixed version is essential for some features of my app. But I also at times enjoy NOT making things wait.

I suspect that Schedule API Workflow’s improper functioning may have been introduced as a “performance enhancement”, but if so it was a poor decision and this fix undoes that – allowing you to actually KNOW when Schedule API Workflow has finished scheduling the API Workflow in question.)

1 Like

This topic was automatically closed after 14 days. New replies are no longer allowed.