MaximeThoonsen/gloria

Solution for Invalid `prisma.question.create()` invocation error

Opened this issue · 11 comments

Hello,

If anyone gets below error upon entering a query in the chat bar, then restart your supabase project (from the project settings page) to resolve it.

PrismaClientUnknownRequestError: 
Invalid `prisma.question.create()` invocation:


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(E42P05), message: "prepared statement \"s1\" already exists", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("prepare.c"), line: Some(412), routine: Some("StorePreparedStatement") }) }), transient: false })

Hello @nikhilno1 ,
You had this problem after creating the tables? After that everything is fine?

I had this problem twice. First time in the local dev environment. Later when I pushed to prod on vercel, ran into the same problem. Both times restarting the project resolved the problem. Tables were already created. Thanks.

Unfortunately, I keep hitting the error on a regular basis and have to restart the project :(

@nikhilno1 do you have the problem if you use a db in local? (With the provided docker-compose file you can have a db quickly)

I haven't tried local DB.
I found prisma/prisma#11643 that suggested including ?pgbouncer=true as part of the DATABASE_URL. After adding that I haven't seen the issue but facing another problem.
The query is working for small answers, but for slightly longer passages getting 504 error.
Have you faced this anytime?

And seeing this error more for production deployment. In local dev environment it works.

@MaximeThoonsen : I am facing this problem quite consistently now. Query is working on dev but not working in prod. I am trying to debug but do share if you have any thoughts on this.

Found out the issue. Root-cause was that free plan on both vercel and netlify have 10 secs timeout for functions. After upgrading to pro plan and increasing the timeout from 10 secs to 30 secs, everything is working now.

Hey @nikhilno1 ,
It should be 30s for edge function: https://vercel.com/docs/concepts/limits/overview
I also use the pro plan for my prod but it was before I used edge function. If it doesn't work it's a shame :/

It is 10.
image
It's not enough to just migrate to pro plan. We have to add below lines in vercel.json and do a fresh deployment.

"functions": {
    "pages/api/answer.ts": {
      "maxDuration": 30
    }

Ok. What I don't understand is that edge function looks like to have a different timeout.
You are stil using this in the answer route?

export const config = {
  runtime: 'edge',
}

Anyway thanks to have spotted that. If you want to make a pr to get the credit, feel free otherwise I'll do it later

You are still using this in the answer route?
Yes, I am.

What is it that you are looking to get fixed? Increasing maxDuration to 30 sec? But that needs pro plan. Not all users will have that.