Migrating Auth0 Node.js V18 to V22
Last Updated:
Overview
This article guides migrating Auth0 Actions from version 18 to version 22. It covers potential breaking changes, best practices for a smooth transition, and testing recommendations to ensure minimal disruption.
Applies To
- Auth0 Actions
- Users migrating from Node.js V18 to V22 in Actions
Cause
Auth0 periodically updates the Node.js runtime for Actions to provide improved security, performance, and access to new language features. As part of this process, users migrating from V18 to V22 may have concerns about potential breaking changes.
Solution
Potential Changes
Though the known required changes for migrating from Node 18 to Node 22 are a short list and related to relatively less common usages, please review the migration guideline below in the reference section carefully to ensure there will be no impact.
Recommended Migration Steps
- Test migration in a development or staging tenant before applying changes to production.
- Validate critical workflows like login, token exchange, and custom logic implemented in Actions.
- Monitor logs for any unexpected errors or warnings after migration.
Best Practices
- Variables should be scoped inside of the Action method (for example, inside of
onExecutePostLogin()) unless the variables in question are intended to be shared between different executions of an Action. - NPM Modules should typically be imported outside of the Action function scope. This will allow modules to be reused across executions without reloading each time.
- Stateful Modules, such as Sentry, Application Insights, Datadog, etc., should also be initialized outside the Action function scope so they are loaded once and reused without the expense of reinitialization.
NOTE: Use caution when defining variables at a module scope. Any user/customer data will be shared across different invocations of the action for different users; therefore, user-related information should always be scoped to the Actions handler.
- Outbound calls should always have a timeout.
NOTE: Migration is encouraged to take advantage of the latest updates and improvements.