-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime Error: Authentication crash when using PrismaAdapter (mongodb) - TypeError: Cannot read properties of undefined (reading 'exec') #12731
Comments
The @auth/prisma-adapter version ^2.8.0 is not compatible with next-auth version ^5.0.0-beta.25. To resolve this issue, revert to @auth/prisma-adapter version 2.7.2 and install it without the ^ symbol to prevent unintended updates. |
Thanks I will try it |
I am having the same error with a similar stack :
using PostgreSQL / Neon (I don't think the actual DB is related to this issue). Thankfully, I got this error at build time, this was a bit more explicit than your logs :
For reference, the source of the related files // Following this guide
// https://authjs.dev/getting-started/adapters/prisma
import { PrismaAdapter } from "@auth/prisma-adapter";
import type { PrismaNeon } from "@prisma/adapter-neon";
import type { PrismaClient } from "@prisma/client";
import type { NextAuthConfig } from "next-auth";
import NextAuth from "next-auth";
import GitHub from "next-auth/providers/github";
import prisma from "@/lib/prisma";
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [GitHub],
callbacks: {
session({ session, user }) {
// As seen on https://authjs.dev/guides/role-based-access-control
if (user?.id) session.user.id = user.id;
if (user?.role) session.user.role = user.role;
return session;
},
},
adapter: PrismaAdapter(
prisma as PrismaClient<{ adapter: PrismaNeon }>,
) as NextAuthConfig["adapter"], // Need to type cast as we extend the payload of session
});
// Only one middleware, used to refresh the token
export { auth as middleware } from "@/lib/auth"; @activemonkeys @th3f0r3ign3r not that it fixes the current problem, in my case I was able to lock version |
I almost forgot my problem is solved |
Great 👍 I will try |
Shit like this is exactly why I hate but also love NextAuth, Auth.js, whatever we call it today. |
@th3f0r3ign3r I am not sure why you consider this issue solved, I think prisma-adapter |
my bad though |
Same here, for PrismaAdapter with Postgres |
This comment has been minimized.
This comment has been minimized.
Thanks for pointing this out! I was facing the same issue, and downgrading |
Environment
Reproduction URL
https://github.com/th3f0r3ign3r/authjs-issue.git
Describe the issue
I have setting up Auth.js with Github Oauth and I decided to add PrismaAdapter with (mongodb) to save user account information. Without adding the adapter everything working great. But when I added the Adapter to
@/auth
it crashCleanShot.2025-03-04.at.19.35.44.mp4
How to reproduce
npx prisma generate
src/auth/index.ts
comment the adapters lineclear && npm run dev
don’t forget to runnpm i
Signin with GitHub
If you follow all these steps normally you will have the same error
Expected behavior
Normally they should not have any error. Instead I am doing something wrong but I follow the guide line per line. 😩😩😩
The text was updated successfully, but these errors were encountered: