Bubble is very easy to set up steps in the workflow, and there's a tendency for Bubblers to cram many steps into one workflow.

While this is fine for simple apps, Bubble sometimes does not run their workflows in sequence to be more efficient, and you may find that you are not saving some data correctly or not returning the correct value.

Even though the steps are labelled in sequence, did you know that Bubble sometimes run steps out of sequence(if possible) to optimize workflows?

Knowing how the order of operations work for Bubble will help you avoid some serious pain when you are trying to debug a process later.

How does Bubble run workflows?

For efficiency purposes, workflows run in 'parallel', not 'in sequence'. This means that a workflow step does not necessarily wait for the previous one to complete before running.

Here are some general rules to take note of:

  • Frontend workflow actions run in order but the next action does not wait on the previous action to be complete before triggering.
  • Backend workflows are triggered as soon as the workflow starts. For example, a ‘Schedule API Workflow’ action will be triggered once the entire workflow is triggered even if it is placed last in the sequence.
  • Custom events run in sequence. If Workflow 1 triggers a custom event that starts Workflow 2, Workflow 2 will complete before the remaining actions in Workflow 1 run.
  • Searches aren’t always immediately updated with new data. So if you create a new item, and then try to retrieve it via search, it may or may not work; you should not rely on this.
  • Retrieving a thing from “result of step X” where step X is the “Create…” step should always be safe.

How to ensure my steps run the way I want it to?

In order for you to ensure that your workflows run consistently each time, here are some tips to optimize your workflows:

1. Split your workflows and conditions

When a workflow can have multiple results based on conditions, it is safer to create multiple workflows and place the conditions at the workflow level instead of creating one workflow with all possible actions and placing the conditions at the action level.

Take a look at the interactive video below for an example of how to do it:

2. Place steps that are dependent on other steps in a custom event

In a workflow with two actions, if Step 2 is using a condition based on a search depending on data manipulated in Step 1, then Step 1 should be implemented into a custom event to make sure it is finished before moving on to Step 2. This also works for backend workflows.

3. Use the 'result of step X' operator

The safest way to use data from one step to another is to use the “result of step X” operators instead of searches. This ensures that the workflow will wait till the previous step is completed before using the result, ensuring that you won't end up with empty data.

4. Add a pause before next action

If you find that a workflow keeps running too quickly, you can consider using the 'add a pause before next action' step to wait a pre-defined number of seconds before running the next step.

For more info on workflow actions, you can refer to the Bubble manual:

Actions - Bubble Docs
This section covers actions, which are the steps in a workflow that perform different tasks

Subscribe for more content like this!

If you have any questions, let me know via email or my Twitter.