Sync Problem with workflow

Hello everyone,

I have a problem with a workflow execution. I think something about event synchronization is wrong. The scenario is the following:

The workflow is the one used to Signup a user. Since I track user’s IP address with Ipiphy plugin, before executing the Signup action, I show a Popup based on a condition which search for every users in the db and if it finds a match against the current IP address, it terminates the workflow. The problems are the following:

  1. The popup is showed in Debug Mode.
  2. Without the Debug Mode activated, the popup is showed only sometime randomly.

I though the steps inside a workflow were executed sequentially.

Can someone explain me how can I solve this issue!?

You’re experiencing a race condition.

They’re not :sweat_smile:. They are triggered sequentially but run in parallel and there is no guarantee that they will finish sequentially. There is a lot of debate/posts about order of operation on the forum, with a lot of information about how you can fix/account for race conditions.

Here is a useful post to start you off:

Hi, thanks for your answer.

Now, according to the post, inside the Signup workflow I trigger the CannotSignupEvent and the SignupEvent based on conditions.

The problem is that now the sub workflow is executed even if the condition is not met. How is this allowed?

3

Custom events are a great way to deal with race conditions.

What are the conditions on the two workflows? The issue must lie here. Which of the two workflows are executing when you believe they shouldnt?

One thing to keep in mind is that Custom workflows run sequentially and finish running before further conditionals are evaluated. Does running the first custom workflow guarantee that the second custom event’s conditional evaluates to true?

The condition is the following.

The difference in the TriggerSignupEvent is only ‘count is 0’.

Here is what I want to happen.

Pre-Condition: I have already a saved user in the DB with an “x” IP.

  1. A new user with the same “x” IP signup by clicking the Signup Button.
  2. At this point we are in the workflow where I have the two triggers.
  3. Since the condition about ‘count > 0’ should be true, the CannotSignupEvent should be fired up.
  4. End.

The problem always seems to be related to asynchronous behavior because in Debug mode seems to work and when debug mode is set to false, sometimes it works and sometimes not.


I thought that maybe the problem could be related to the API call from the Ipiphy plugin to get the IP data but honestly I don’t know.

Yes there is probably an issue with plugin’s API response delay.

In this particular case an easy solution would be to move the API call before the Button is clicked. The IP of the user does not change so you can make the query when you open the signup page/popup for example. Save the IP address to a text custom state and then run the search with the custom state instead of an API call.

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