How can I ensure that the Post-Registration process is completed before redirecting when using Auth0 Lock?

I’ve observed that Auth0 Lock skips the Post-Registration step and runs in the background, causing issues such as missing user data in our database when the redirect occurs.

For instance:

Auth0 Lock → Skips Post-Registration (Auth0 actions) → Redirects → API fails due to incomplete user data in our database

Expected behavior:

Auth0 Lock → Waits and completes Post-Registration first → Redirects → API succeeds

We utilize Post-Registration (Auth0 action) to save user data to the database.

I’m uncertain why it’s skipping the Post-Registration step and proceeding directly to the redirect.

Here’s a code example:

const axios = require("axios");

/**
 * Handler that will be called during the execution of a PostUserRegistration flow.
 *
 * @param {Event} event - Details about the context and user that has registered.
 * @param {PostUserRegistrationAPI} api - Methods and utilities to help change the behavior after a signup.
 */
exports.onExecutePostUserRegistration = async (event, api) => {
  console.log(JSON.stringify(event));
  console.log("Saving user Data");
  // create user in our db
  await axios
    .post(`https://exampleco.com/user`, {
      ...event.user,
    })
    .then((res) => {
      console.log(`statusCode: ${res.status}`);
    })
    .catch((err) => {
      console.error(err);
    });

  console.log("Saved user Data");
};

Hi @team4,

Using Lock should have no impact on whether or not the post registration action runs.

Post registration actions are non-blocking, and the auth pipeline does not wait for them to complete before continuing. Additionally, they only run for Database and Passwordless connections.

Hope this helps!