Clerk: Wait until Convex also set up the user

Currently, I have this code:
      if (!isLoaded) {
        setIsLoading(false);
        // We probably need a toast showing that the user has to try again or use a better way.
        return;
      }
      const result = await signIn.create({
        identifier: values.username + values.usernameId,
        password: values.password,
      });

      if (result.status === "complete") {
        await setActive({ session: result.createdSessionId });
        void initialConvexSetup();
        router.push("/");
      }

If I call the initialConvexSetup function here it's giving me an error that I'm not authenticated.

This is because Convex is taking more time for the authentication setup than a clerk. because all other function I run after that initialSetup work.

How can I wait until convex also is done with the setup?
Was this page helpful?