Critically Talented
Critically Talented
CCConvex Community
Created by Critically Talented on 5/3/2025 in #support-community
Clerk + Convex Custom Sign-up Flow Race Conditions
Hey everyone, Here is a summary of what had been discussed on the clerk-channel here in the convex community, and I really need some help figuring out an issue I'm facing with Convex + Clerk integration during a custom sign-up flow. The Context: I'm implementing a custom multi-step onboarding flow (6 steps). At step 3, the user signs up/signs in using Clerk, but I'm using a custom sign-in flow as described here: Clerk Docs – Custom Sign-In Flow. This means I manually handle user creation, email verification, and setting the Clerk session as active using setActive. Once the email is verified and the session is successfully set as active with setActive, I need to immediately call a Convex mutation (initializeUser) to create a user record in my users table. This record stores essential data and their current onboarding step (e.g., profileState: "pending_step4"). This is crucial so if the user drops off, they can resume later from where they left off. I avoid creating this DB record before step 3 because the user isn't verified yet, and there's no point saving incomplete/unauthenticated data if they might just leave.
7 replies