I encountered an issue while using Auth0 with a custom database. When testing the custom database scripts, everything works as expected. Deleting a user via the Auth0 dashboard also works perfectly. However, when I attempt to delete a user using the Management API, I receive the following error: Request to Webtask exceeded allowed execution time.
Upon investigating the logs, I noticed that the delete user endpoint in my script is only accessed after the error is thrown.
Could you please help me identify what might be causing this issue? Specifically:
Why is the delete user endpoint not called immediately?
How can I ensure the script executes within the allowed time limit?
Regarding why the delete user endpoint isn’t called immediately:
When using the Management API to delete a user, Auth0 first attempts to perform some internal cleanup operations
This includes removing the user from any organizations, revoking refresh tokens, and cleaning up any associated data
Only after these operations complete does Auth0 call your custom database delete script
If these preliminary operations take too long, the webtask times out before reaching your script
These posts can help you explain why you receiving the error.
If the issue persists, you could consider implementing a queue-based system for user deletion, where the Management API triggers a deletion request that gets processed asynchronously, though this would require additional infrastructure.