K
Kinde5mo ago
Woet

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:
Attempt 1 - Error fetching JWKS: DOMException [AbortError]: This operation was aborted
at node:internal/deps/undici/undici:13502:13
at async Zu.t.fetch (/opt/edge/handler.js:235:5825)
at async Uc (user-source.js:110:66880)
at async Gs (user-source.js:110:67243)
at async qc (user-source.js:110:69350)
at async Ws (user-source.js:110:69673)
at async Yo (user-source.js:110:82909)
at async Vl (user-source.js:110:342086)
at async i (user-source.js:110:368035)
at async handler (user-source.js:124:4328)
Attempt 2 - Error fetching JWKS: DOMException [AbortError]: This operation was aborted
at node:internal/deps/undici/undici:13502:13
at async Zu.t.fetch (/opt/edge/handler.js:235:5825)
at async Uc (user-source.js:110:66880)
at async Gs (user-source.js:110:67243)
at async qc (user-source.js:110:69350)
at async Ws (user-source.js:110:69673)
at async Yo (user-source.js:110:82909)
at async Vl (user-source.js:110:342086)
at async i (user-source.js:110:368035)
at async handler (user-source.js:124:4328)
Attempt 1 - Error fetching JWKS: DOMException [AbortError]: This operation was aborted
at node:internal/deps/undici/undici:13502:13
at async Zu.t.fetch (/opt/edge/handler.js:235:5825)
at async Uc (user-source.js:110:66880)
at async Gs (user-source.js:110:67243)
at async qc (user-source.js:110:69350)
at async Ws (user-source.js:110:69673)
at async Yo (user-source.js:110:82909)
at async Vl (user-source.js:110:342086)
at async i (user-source.js:110:368035)
at async handler (user-source.js:124:4328)
Attempt 2 - Error fetching JWKS: DOMException [AbortError]: This operation was aborted
at node:internal/deps/undici/undici:13502:13
at async Zu.t.fetch (/opt/edge/handler.js:235:5825)
at async Uc (user-source.js:110:66880)
at async Gs (user-source.js:110:67243)
at async qc (user-source.js:110:69350)
at async Ws (user-source.js:110:69673)
at async Yo (user-source.js:110:82909)
at async Vl (user-source.js:110:342086)
at async i (user-source.js:110:368035)
at async handler (user-source.js:124:4328)
No description
No description
7 Replies
Woet
WoetOP5mo ago
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?
Roshan
Roshan5mo ago
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, 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
Woet
WoetOP4mo ago
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
Roshan
Roshan4mo ago
We're currently reviewing to identify the root cause and will get back to you asap. Thanks again for your patience!
Abdelrahman Zaki - Kinde
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.
Woet
WoetOP4mo ago
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.
Abdelrahman Zaki - Kinde
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!

Did you find this page helpful?