# NextJS - access\_denied (Script execution time exceeded)

**URL:** <https://community.auth0.com/t/nextjs-access-denied-script-execution-time-exceeded/87186>\
**Category:** Get Help\
**Tags:** react, nextjs, login, auth0\
**Created:** [July 19, 2022, 12:04pm UTC](https://community.auth0.com/t/nextjs-access-denied-script-execution-time-exceeded/87186 "2022-07-19T12:04:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zachary.willard](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/zachary.willard/32/38837_2.png) [@zachary.willard](https://community.auth0.com/u/zachary.willard)\
**Post date:** [July 19, 2022, 12:04pm UTC](https://community.auth0.com/t/nextjs-access-denied-script-execution-time-exceeded/87186/1 "2022-07-19T12:04:49Z")

</div>

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](https://github.com/auth0/nextjs-auth0)

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

```auto
access_denied (Script execution time exceeded)

```

Upon hitting refresh the client sees

```auto
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.

---

<div class="post-metadata">

**Author:** ![art.stupels](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/art.stupels/32/30429_2.png) [@art.stupels](https://community.auth0.com/u/art.stupels)\
**Post date:** [July 24, 2022, 3:08pm UTC](https://community.auth0.com/t/nextjs-access-denied-script-execution-time-exceeded/87186/2 "2022-07-24T15:08:25Z")

</div>

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](https://manage.auth0.com/#/logs?q=type%3Af) filtered by:

```auto
type:f

```

As per [documentation](https://auth0.com/docs/customize/actions/limitations):

> 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](https://auth0.com/docs/customize/extensions/real-time-webtask-logs) as it helps to debug the issues like this one.

Thanks,  
Art

---

<div class="post-metadata">

**Author:** ![zachary.willard](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/zachary.willard/32/38837_2.png) [@zachary.willard](https://community.auth0.com/u/zachary.willard)\
**Post date:** [July 25, 2022, 6:52pm UTC](https://community.auth0.com/t/nextjs-access-denied-script-execution-time-exceeded/87186/3 "2022-07-25T18:52:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [July 28, 2022, 1:22pm UTC](https://community.auth0.com/t/nextjs-access-denied-script-execution-time-exceeded/87186/4 "2022-07-28T13:22:23Z")

</div>

Is it something specific that other users can benefit from?

---

<div class="post-metadata">

**Author:** ![zachary.willard](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/zachary.willard/32/38837_2.png) [@zachary.willard](https://community.auth0.com/u/zachary.willard)\
**Post date:** [July 28, 2022, 1:51pm UTC](https://community.auth0.com/t/nextjs-access-denied-script-execution-time-exceeded/87186/5 "2022-07-28T13:51:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lydiaocie](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lydiaocie/32/46289_2.png) [@lydiaocie](https://community.auth0.com/u/lydiaocie)\
**Post date:** [April 3, 2023, 10:04am UTC](https://community.auth0.com/t/nextjs-access-denied-script-execution-time-exceeded/87186/6 "2023-04-03T10:04:24Z")

</div>

thank you so much it was really helpful
