Hi. I'm new here. I'm building a Next.js app and u...
# orm-help
n
Hi. I'm new here. I'm building a Next.js app and using NextAuth. I keep getting the following error:
Copy code
[next-auth][error][adapter_error_getSessionAndUser] 
<https://next-auth.js.org/errors#adapter_error_getsessionanduser> 
Invalid `p.session.findUnique()` invocation in
/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@next-auth/prisma-adapter/dist/index.js:22:52

  19 linkAccount: (data) => p.account.create({ data }),
  20 unlinkAccount: (provider_providerAccountId) => p.account.delete({ where: { provider_providerAccountId } }),
  21 async getSessionAndUser(sessionToken) {
→ 22     const userAndSession = await p.session.findUnique(
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E26000), message: "prepared statement \"s56\" does not exist", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("prepare.c"), line: Some(485), routine: Some("FetchPreparedStatement") }) }) }) {
  message: '\n' +
    'Invalid `p.session.findUnique()` invocation in\n' +
    '/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@next-auth/prisma-adapter/dist/index.js:22:52\n' +
    '\n' +
    '  19 linkAccount: (data) => p.account.create({ data }),\n' +
    '  20 unlinkAccount: (provider_providerAccountId) => p.account.delete({ where: { provider_providerAccountId } }),\n' +
    '  21 async getSessionAndUser(sessionToken) {\n' +
    '→ 22     const userAndSession = await p.session.findUnique(\n' +
    'Error occurred during query execution:\n' +
    'ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E26000), message: "prepared statement \\"s56\\" does not exist", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("prepare.c"), line: Some(485), routine: Some("FetchPreparedStatement") }) }) })',
  stack: 'Error: \n' +
    'Invalid `p.session.findUnique()` invocation in\n' +
    '/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@next-auth/prisma-adapter/dist/index.js:22:52\n' +
    '\n' +
    '  19 linkAccount: (data) => p.account.create({ data }),\n' +
    '  20 unlinkAccount: (provider_providerAccountId) => p.account.delete({ where: { provider_providerAccountId } }),\n' +
    '  21 async getSessionAndUser(sessionToken) {\n' +
    '→ 22     const userAndSession = await p.session.findUnique(\n' +
    'Error occurred during query execution:\n' +
    'ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E26000), message: "prepared statement \\"s56\\" does not exist", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("prepare.c"), line: Some(485), routine: Some("FetchPreparedStatement") }) }) })\n' +
    '    at RequestHandler.handleRequestError (/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@prisma/client/runtime/index.js:30855:13)\n' +
    '    at RequestHandler.request (/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@prisma/client/runtime/index.js:30834:12)\n' +
    '    at async PrismaClient._request (/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@prisma/client/runtime/index.js:31812:16)\n' +
    '    at async getSessionAndUser (/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@next-auth/prisma-adapter/dist/index.js:22:36)',
  name: 'Error'
}
[next-auth][error][SESSION_ERROR] 
<https://next-auth.js.org/errors#session_error> 
Invalid `p.session.findUnique()` invocation in
/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@next-auth/prisma-adapter/dist/index.js:22:52

  19 linkAccount: (data) => p.account.create({ data }),
  20 unlinkAccount: (provider_providerAccountId) => p.account.delete({ where: { provider_providerAccountId } }),
  21 async getSessionAndUser(sessionToken) {
→ 22     const userAndSession = await p.session.findUnique(
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E26000), message: "prepared statement \"s56\" does not exist", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("prepare.c"), line: Some(485), routine: Some("FetchPreparedStatement") }) }) }) Error: 
Invalid `p.session.findUnique()` invocation in
/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@next-auth/prisma-adapter/dist/index.js:22:52

  19 linkAccount: (data) => p.account.create({ data }),
  20 unlinkAccount: (provider_providerAccountId) => p.account.delete({ where: { provider_providerAccountId } }),
  21 async getSessionAndUser(sessionToken) {
→ 22     const userAndSession = await p.session.findUnique(
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E26000), message: "prepared statement \"s56\" does not exist", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("prepare.c"), line: Some(485), routine: Some("FetchPreparedStatement") }) }) })
    at RequestHandler.handleRequestError (/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@prisma/client/runtime/index.js:30855:13)
    at RequestHandler.request (/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@prisma/client/runtime/index.js:30834:12)
    at async PrismaClient._request (/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@prisma/client/runtime/index.js:31812:16)
    at async getSessionAndUser (/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@next-auth/prisma-adapter/dist/index.js:22:36) {
  name: 'GetSessionAndUserError',
  code: undefined
}
The app is running on Supabase. Restarting the app server makes it go away. Any ideas on how to troubleshoot / fix this? Thanks in advance!
👀 1
1
v
hi - have you tried the supabase discord server ? this might be more appropriate question for that community
n
Hello @Neil Girardi 👋 Welcome to our community! prisma cool Can you have a look at this GitHub Issue? It seems you are running into this same issue. Would you be able to provide us full output information as described in this comment?
n
@Nurul Thank you for the prompt response! Forgive me for asking such a basic question, but is the correct way to add that environment variable to export it from the client like so?
Copy code
//src/Utilities/PrismaClient.js
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
export default prisma
export const DEBUG="prisma:*"
Or am I supposed to have a config file on my local file system?
n
On the CLI in which you are running your app you could export the debug variable and then when you start the application server you should get all the logs, something like the image attached.
n
@Nurul Got it. Thanks! Now that I have the debugging running I will post when it happens again.
👍 1
@Nurul I got the error again and this time I had the DEBUG set in the terminal. This is the full output. Note, it seems that this error happens when starting up the app. When this happens, I usually have to login to Supabase, where my Postgres DB is hosted, and restart the app.