Issue with Workflow Order – Custom Events Executing Out of Sequence

Hello! I’m experiencing an issue where my workflows made with Custom Events are not executing in the expected sequence. I have a process for creating a session that involves two validation steps before the session is actually created. However, Bubble seems to execute the “Create Session” step before completing the validation steps.

Expected Workflow:

  1. Button Clicked → Triggers “Check for Duplicates”.
  2. Custom Event: “Check for Duplicates”
  • If a duplicate is found (count > 0), show an error and terminate workflow.
  • If no duplicate is found, trigger “Check for Overlaps”.
  1. Custom Event: “Check for Overlaps”
  • If an overlapping session exists (count > 0), show an error and terminate workflow.
  • If no overlap is found, trigger “Create Session”.
  1. Custom Event: “Create Session”
  • Only executes if called from “Check for Overlaps”.
  • Creates the session and shows a success message.

The Problem:

  • Even when a duplicate or an overlapping session is found, Bubble still creates the session.
  • I added “Terminate this workflow” in both validation events, but it doesn’t stop the execution.
  • I tried using Custom States (can_create_session = Yes/No), but this didn’t help—when updating the state, Bubble immediately creates the session before completing the validations.
  • I also tested removing all unnecessary workflow steps and only triggering events in sequence, but it still misfires.

:small_blue_diamond: What I Need Help With:

  • Ensuring that Bubble does not execute the “Create Session” step unless all validations pass.
  • Understanding why Terminate this workflow is not stopping execution within Custom Events.
  • Confirming if there is an internal Bubble behavior that might be causing workflows to run in parallel instead of sequentially.

I’ve tested multiple approaches, but none seem to solve the issue. I would appreciate some help!

I attach some screenshots of my Workflow.




Thank you!

Conditions to execute the Terminate this workflow actions and those for invoking Custom Events (CEs) are mutually exclusive, so the fact that the process keeps invoking the next CE is not in contradiction with the Terminate this workflow actions not being executed.

The problem here seems to be that the invocation of CEs is apparently firing when it shouldn’t. So, we should have a look at the conditional allowing to invoke the CEs.

Can you confirm that the condition evaluates to something you don’t expect?

I’d recommend going through the debugger step-by-step and checking those conditions which are failing to trigger the terminate action

I didn’t know about the “Terminate this Workflow” behaivour. Thank you.

The conditions are not the problem. They behave as expected if I delete de CE “Create Session NP”. The problem is that the session is created before anything else, and it makes everything to fail.

Debugging step by step everything follows the woorkflow as it should, but the problem is that as the session is created at first (for some reason I don’t know).

May it be a bug?

1 Like

The problem is that as the session is being created at the beggining (I don’t know why) it triggers the ‘wrong’ conditions.

Workflow actions on the front-end shouldn’t run asynchronously so I don’t think that’s the problem.

What are the search parameters on this action? It could be that this action is failing to set it to yes

Search for Sessions:count is 0
image

If I understand, you have the same condition here, it could be either your Search for Sessions:count is 0 is not set up properly, or your Group Widget Nueva sesion NP's Crear Sesion is yes is actually no

I did find a useful thread here

It seems like there might be a race condition in your logic, but I wouldn’t know unless we dug deeper into the workflows and debugger / logs.

Weird thing. What should these Verificar Duplicados and Verificar Solapadas CEs conditions evaluate to when the bug happens? True or false?

  • Only when Search for Sesions:count > 0
  • Only when Search for Sesions:count is 0

Hi! Thanks for taking your time and answer.

The ‘Set State’ is not changing nothing, actually. If I delete it, it will run the same way. I just put it in order to add another conditional, but it does not works.

The problem is when there is the action “Create a Session”. When I put it, it will be created before anything else.

I’ll try to post a video so you guys can see.

Only when Search for Sesions:count > 0 is the condition that detects duplicates. If there is another session that has the same information as the one that is being created, then shows an alert and should end the workflow (or in that case, should not pass to the next CE).

Right now, when the bug happens it is evaluating:
Only when Search for Sesions:count > 0 as True
and
Only when Search for Sesions:count is 0 as False, but just from the CEVerificar Duplicados, because once evaluates it as False, the Workflow ends.

In order to create the session:
The Only when Search for Sesions:count > 0 condition from both CE should be False
and
The Only when Search for Sesions:count is 0 condition from both CE should be True.

In order to verify we are dealing with a bug, try placing a couple Text elements on screen that show the results of both conditionals, with exact same constraints for the Search for expressions.

If they return this below, and the Sesion gets created, we are seeing a normal behaviour, no bug.

If we see this, and the Sesion gets created, then it’s a bug.

1 Like

Video where you can see the Step by Step and the premature creation of the session.

Sorry, but I did not understand exactly how to do that.

In case it is useful, I did a video where you can see how the session is created before anything else. If not, could you explain me exactly what to do, please? Thanks!

Video - Step by Step and the premature creation of the session.

Definitely looks odd, I would go back through your server logs from 3:00-3:02 and see what action triggered to create the item in the DB, it could be firing from another action that’s not included in your custom event, otherwise it might be a bug.

This is a weird behaviour of the debugger, I’ve seen it before.

But I see no bug in your execution, the Sesion gets created because there is no duplicated Sesion in DB.

If you try executing it again an a second exact Sesion gets created, then it’s a bug.

But that weird execution is triggering the alerts. Then when someone is creating a session, always will appear the alert “That session was not created because is a duplicate”.

How can I solve it?

Try executing it without the debugger, just as a normal user would do.

Let’s see if the bug is present then.

I looked and I think there’s something weird. I am not used to look at the logs, but it starts with the “terminate this workflow” conditions:


Same problem running normal.

Please record another video, running without the debugger active, showing the next steps:

  1. Show DB table for Sesion
  2. Click the button. It should run without alert being shown. Sesion should get created.
  3. Show DB table for Sesion again. The newly createdSesion should be there.
  4. Click the button again (I guess this will try to create a duplicated session). The alert should show now. No new Sesion should be created.
  5. Show DB table for Sesion again. No newSesion should be there.

If what’s described in previous steps don’t happen as expected, show logs

from a programming point of view instead of nesting your workflows like that, create your 3 workflows and have them each return a value (return a value step is hard to find so just type return when you are creating the step).

have the top level work flow call the first one (which will have a value) then the second one only if the first step condition was met. Then the third one only of the original conditions are met.

In general your custom event should take parameters and return values rather than pulling in information from all over the place. This keeps the workflow tidy and allows you to test it more easily.

1 Like