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.