I’ve seen this in other posts, and also read in bubble documentation, yet still running into issues.
Is it true that a step down the line of a workflow event could run before other steps, and the debugger will not land on it?
Here’s the scenario:
User presses a button which checks if data they just entered exists.
Step 1 triggers a custom event that checks the database for the a record with the number they entered and a specific status, let’s call it A.
Step 2 triggers a custom event if the record is not in status A.
Step 3 triggers a custom event if the record is in status A, and then makes changes to the thing to status B.
What happens in actual life is that the “Make changes to a thing” step in the event triggered in step 3 of the parent event runs before anything else without a trace in the debugger, and when the workflow hits step 2 the record is already in status B, which causes it to trigger.
I put every step into a triggered event as I understood from bubble’s documents that triggered events from an event do in fact run synchronously.
I try to run the debugger to trace the problem, but frustratingly I see the database change but the debugger runs synchronously.
I ended up using a 1 second pause in event in step 1, and a state that updates only when that step is complete, and that stops this kind of behavior. But this seems risky to me as the search could take longer than a second at a very busy time. Suspending for more than a second could result in a not so friendly UX.
Is this a known bug, or am I missing something?
Thanks in advance for any further light on this matter.
Yes. Bubble runs actions in parallel where possible always. Using custom events to achieve a truly chain-like process may be more of an art given what you described. Without seeing the specifics it is difficult to provide specific advice.
As a first pass …. Try using “result of” as much as possible and trigger chained logic … as a chain.
From my experience “result of” works only if the action is an api call or a creation of a thing. Here I don’t create a thing, only query the database.
Additionally in the post you linked to it says that using custom events will help control order of run, but I found that not to be true. I do my database search in one custom event and the update in another, yet the first thing that happens in that workflow is the database update, which renders the first custom event - the database query, irrelevant.
This is exactly what I’m doing.
But again, two problems:
I can’t use the result of action 1 because it is a do search - search of the database , which doesn’t render itself to be used directly in proceeding steps.
Bubble doesn’t care about my daisy chain. It seems to scan all the actions in the custom events down the chain, and if there’s an update to the database it runs that first. And it doesn’t even show it to you in the debugger so I can’t even trace what is going on.