Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web-channel): race condition from visit event #12435

Merged
merged 1 commit into from Jan 23, 2023

Conversation

davidvitora
Copy link
Contributor

@davidvitora davidvitora commented Dec 28, 2022

The visit event today is being intercepted by the web-channel backend; in the handler, we update some user variables using bp.users.updateAttributes, which creates a race condition if there is a proactive hook and the flow changes some user variables in an action or an entry node, for example. This isn't easy to reproduce but has been happening for some managed clients, but happens in one of 50 interactions.

I could reproduce it by using a puppeteer automated test with a proactive hook + 3 new events sent by the front end simultaneously (events that change the user variable).

image

image

image

image

What happens is that when the issue occurs, the isSet4 variable gets overwritten by the bp.users.updateAttributes call. I was able to fix it by converting the visit message event to a data event and handling the user state update in a hook, this way, the visit event is sent to the event queue and gets executed sequentially.

@vercel
Copy link

vercel bot commented Dec 28, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
botpress-v12-docs ✅ Ready (Inspect) Visit Preview Dec 28, 2022 at 8:02PM (UTC)

@davidvitora davidvitora requested a review from EFF December 28, 2022 20:02
Copy link
Member

@EFF EFF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM good work

@davidvitora davidvitora merged commit a04f4e4 into master Jan 23, 2023
@davidvitora davidvitora deleted the dv_fix_dialog_race branch January 23, 2023 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants