Nextjs-auth0 sometimes throws a TypeError at NodeCookies.getSetCookieHeader when idle

Hi everyone,

I’m currently getting this error every once in a while after a two days or so of being idle. Clearing my cookies and logging back in fixes the issue. The error message I’m getting is:

TypeError: Cannot read properties of undefined (reading 'getHeader')
at NodeCookies.getSetCookieHeader (<repo_path>/master/node_modules/@auth0/nextjs-auth0/dist/auth0-session/utils/cookies.js:47:27)
at Cookies.commit (<repo_path>/master/node_modules/@auth0/nextjs-auth0/dist/auth0-session/utils/cookies.js:31:36)
at StatelessSession.<anonymous> (<repo_path>/master/node_modules/@auth0/nextjs-auth0/dist/auth0-session/session/stateless-session.js:204:38)
at step (<repo_path>/master/node_modules/tslib/tslib.js:193:27)
at Object.next (<repo_path>/master/node_modules/tslib/tslib.js:174:57)
at fulfilled (<repo_path>/master/node_modules/tslib/tslib.js:164:62) {
page: '/dashboard/manage-events'
}

I’m not sure what’s causing the issue, but it seems to be related to the ‘getHeader’ property of an undefined variable. I’m working with the @auth0/nextjs-auth0 package, and the error is being thrown from the cookies.js file.

Has anybody encountered this issue or know what else I should be looking at to fix it?

I’ve tried updating the package, but it’s already at the latest version and this still occasionally happens, so far it has only happened on local but am afraid it will happen on prod.

Thanks!

Now it has happened in production… Wondering if anyone has run into this?

Stack:
NextJs@13.2.3
@auth0/nextjs-auth0@2.4.0

I guess if no one has an answer right away, does anybody know what’s the correct way of handling this in nextjs?

I’m having issue figuring out where the error is coming from, I’m unsure how to detect the error if it’s coming from […auth0].js