URGENT - Next.js - crashing middleware because JWKS can't be fetch
Can somebody please help?
I had upgraded to @kinde-oss/[email protected], but after that, I've started experiencing errors when fetching the JWKS.
This happens in the middleware and thus my application crashes.
I've tried rolling back to a previous version on prod, but so far the crash is still occuring.
These are the error details:


7 Replies
Ok, looks like I've managed to rollback to a version on prod that doesn't cause a crash, so it's less urgent. But still seems worth looking into why this happened after the update?
Hey, Thanks for reaching out.
It appears that the issue may be related to how the SDK handles token validation in the middleware layer, which could involve a background request to fetch JWKS keys. The SDK has undergone significant changes in how it handles authentication state and session management. For example,
Would you be able to create a bug report on the project's GitHub repository? That will help the development team track and resolve the issue more efficiently.
Thanks
It appears that the issue may be related to how the SDK handles token validation in the middleware layer, which could involve a background request to fetch JWKS keys. The SDK has undergone significant changes in how it handles authentication state and session management. For example,
getKindeServerSession
now returns promises that need to be properly awaited.
I’ll go ahead and forward this to our development team so they can take a closer look and confirm the exact cause.
In the meantime, could you let me know which SDK version you're currently using that is working for you? That will help us narrow it down further.
Thanks again for your patience!
Hi Again,Would you be able to create a bug report on the project's GitHub repository? That will help the development team track and resolve the issue more efficiently.
Thanks
Of course, I'm not sure what was causing the error though, only this log in Vercel
Unfortunately happened today during a meeting with a customer, even though I hadn't made any changes, so I do hope you'll be able to pinpoint whats causing these errors
We're currently reviewing to identify the root cause and will get back to you asap.
Thanks again for your patience!
Hi @Woet, thanks again for your updates — and I’m really sorry to hear this happened during a customer meeting.
From the logs you’ve shared, it looks like the issue might be related to the Next.js configuration rather than the SDK itself. Just to help rule that out, we’ve put together a starter kit with full support for the App Router and recommended setup practices:
👉 https://github.com/kinde-starter-kits/kinde-nextjs-app-router-starter-kit
Would you be open to trying it out locally or in a staging environment to see if the issue persists there? That would really help us isolate the cause.
Let us know how it goes — we’re here to help every step of the way.
GitHub
GitHub - kinde-starter-kits/kinde-nextjs-app-router-starter-kit: Ki...
Kinde NextJS SDK with full App Router support. Contribute to kinde-starter-kits/kinde-nextjs-app-router-starter-kit development by creating an account on GitHub.
Hi @Abdelrahman Zaki - Kinde , thanks for the update. I'll take a look at the starter kit and see if there's anything I can improve with my current setup.
Thanks @Woet - appreciate you taking the time to look into it. Let us know if anything stands out or if you'd like a second pair of eyes on your current setup. Happy to help troubleshoot further if needed!