NextJS - access_denied (Script execution time exceeded)

Hello - I am trying to solve an intermittent issue where the client is unable to access the application after authenticating.

We are using:
Nextjs 12.1.6
@auth0/nextjs-auth0 1.9.0: GitHub - auth0/nextjs-auth0: Next.js SDK for signing in with Auth0

This occurs after logging in and redirecting to the /api/auth/callback route for our application

access_denied (Script execution time exceeded)

Upon hitting refresh the client sees

checks.state argument is missing

The client reported that when they tried sometime again later, they were able to login and use the application ok.

Searching the Auth0 community I see reference to a similar message “Request to Webtask exceeded allowed execution time”, but I’m not sure if this is related to nextjs or my issue.

This seems like a timeout issue, but I’m unsure where to add logging to further diagnose / explain the issue. Any leads/ideas would be welcome.

1 Like

Hey Zachary,

The issue is most likely caused by the script execution timeout via Auth0 Actions.

You can usually spot this in the Dashboard > Monitoring > Logs filtered by:


As per documentation:

Each execution of a flow must complete in 10 seconds or less or the processing will end in an error.

I recommend reviewing the Action code, mainly if the Action makes any 3rd party API requests, as that’s the most common cause of the timeout errors.

I recommend installing the Real-time Webtask Logs Extension as it helps to debug the issues like this one.



Thanks Art! I was able to locate the error. This issue is not directly with nextjs itself, but with an Action as you suggested.

1 Like

Is it something specific that other users can benefit from?

An API call is made in the action to our own endpoint, but no mechanism is in place to handle failure (in this case a timeout, probably from a network issue) and assumes a happy path
We are going to try more defensive programming, e.g. timing the API call out sooner and adding a retry mechanism

thank you so much it was really helpful

1 Like