How to resolve 'adapter_error_getUserByAccount' in NextAuth with Prisma

Viewed 245

I'm trying to implement an auth flow in my project using Next.js + NextAuth.js + Prisma. And I'm using GitHub Provider. It works perfectly fine on my local machine, I can sign in and redirect back to the dashboard. I thought it might be a database problem, so I've tested using my production database URL, but still works fine in the local environment. Only in the production mode error occurs.

Below is the error message I got in Vercel.

[GET] /api/auth/callback/github?code=e19191fb050f6a1708e8&state=lV7j49LEjSWE9GHMBWjQ-6WGr62yqziPqhkWURnGBWQ
15:55:11:41
2022-05-16T06:55:11.782Z    4b29fadc-0c2a-4f7a-9140-fbbb45d159f2    ERROR   [next-auth][error][adapter_error_getUserByAccount] 
https://next-auth.js.org/errors#adapter_error_getuserbyaccount Cannot read property 'findUnique' of undefined {
  message: "Cannot read property 'findUnique' of undefined",
  stack: "TypeError: Cannot read property 'findUnique' of undefined\n" +
    '    at getUserByAccount (/var/task/node_modules/@next-auth/prisma-adapter/dist/index.js:11:45)\n' +
    '    at _callee2$ (/var/task/node_modules/next-auth/core/errors.js:315:29)\n' +
    '    at tryCatch (/var/task/node_modules/regenerator-runtime/runtime.js:63:40)\n' +
    '    at Generator.invoke [as _invoke] (/var/task/node_modules/regenerator-runtime/runtime.js:294:22)\n' +
    '    at Generator.next (/var/task/node_modules/regenerator-runtime/runtime.js:119:21)\n' +
    '    at asyncGeneratorStep (/var/task/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)\n' +
    '    at _next (/var/task/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)\n' +
    '    at /var/task/node_modules/@babel/runtime/helpers/asyncToGenerator.js:32:7\n' +
    '    at new Promise (<anonymous>)\n' +
    '    at /var/task/node_modules/@babel/runtime/helpers/asyncToGenerator.js:21:12',
  name: 'TypeError'
}
2022-05-16T06:55:11.783Z    4b29fadc-0c2a-4f7a-9140-fbbb45d159f2    ERROR   [next-auth][error][OAUTH_CALLBACK_HANDLER_ERROR] 
https://next-auth.js.org/errors#oauth_callback_handler_error Cannot read property 'findUnique' of undefined TypeError: Cannot read property 'findUnique' of undefined
    at getUserByAccount (/var/task/node_modules/@next-auth/prisma-adapter/dist/index.js:11:45)
    at _callee2$ (/var/task/node_modules/next-auth/core/errors.js:315:29)
    at tryCatch (/var/task/node_modules/regenerator-runtime/runtime.js:63:40)
    at Generator.invoke [as _invoke] (/var/task/node_modules/regenerator-runtime/runtime.js:294:22)
    at Generator.next (/var/task/node_modules/regenerator-runtime/runtime.js:119:21)
    at asyncGeneratorStep (/var/task/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (/var/task/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
    at /var/task/node_modules/@babel/runtime/helpers/asyncToGenerator.js:32:7
    at new Promise (<anonymous>)
    at /var/task/node_modules/@babel/runtime/helpers/asyncToGenerator.js:21:12 {
  name: 'GetUserByAccountError',
  code: undefined
}

I've read all related threads on GitHub issues and discussions, but still cannot find any way to resolve this problem.

1 Answers
Related