Ted
Ted
PPrisma
Created by Ted on 7/3/2024 in #help-and-questions
URGENT: I cannot remove/uninstall Accelerate from my Vercel build. Help.
I'm trying to remove Accelerate, but Vercel's not having it. I've removed use of extend, removed the package library, changed environment URLs to original Postgres urls. I'm stumped. Please help.
13 replies
PPrisma
Created by Ted on 7/3/2024 in #help-and-questions
How can I simultaneously use Accelerate with directUrl for some uses cases?
I keep getting Error validating datasource db: the URL must start with the protocol prisma://. I want to use my directUrl to bypass Prisma's 5MB limit in one use case. This works on localhost, but not on Vercel preview/production. I specify a Prisma accelerate URL in DATABASE_URL, and a direct url in DIRECT_DATABASE_URL. I'm instantiating prismaDirect this way:
import {PrismaClient} from "@prisma/client"
import {withAccelerate} from "@prisma/extension-accelerate"

export const prisma = new PrismaClient({
log: ['error'], // log: ['query', 'info', 'warn', 'error'],
}).$extends(withAccelerate())

export const prismaDirect = new PrismaClient(
{datasourceUrl: process.env.DIRECT_DATABASE_URL || ''}
)
import {PrismaClient} from "@prisma/client"
import {withAccelerate} from "@prisma/extension-accelerate"

export const prisma = new PrismaClient({
log: ['error'], // log: ['query', 'info', 'warn', 'error'],
}).$extends(withAccelerate())

export const prismaDirect = new PrismaClient(
{datasourceUrl: process.env.DIRECT_DATABASE_URL || ''}
)
and my schema:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_DATABASE_URL")
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_DATABASE_URL")
}
1 replies
PPrisma
Created by Ted on 6/29/2024 in #help-and-questions
Get P6004 and P5000 error running Vercel production query through Accelerate
I receive this error and I don't understand the cause is. The query is straightforward, performing a fetch of 25 rows with a JOIN, no filtering or sorting, that should reply fast with a small handful of columns to populate a MUI DataGridPro React component. This works via Preview and localhost. Accelerate status appears fine today, but not sure about Cloudflare. I hope someone can give me a clue or how to more quickly debug this and get me on track to resolve ASAP. I'm not sure why this is timing out.
PrismaClientKnownRequestError:
Invalid `prisma.$queryRawUnsafe()` invocation:
This request could not be understood by the server: {"type":"UnknownJsonError","body":{"code":"P6004","message":"The Query did not produce a result within the maximum allowed execution time of 10 seconds."}} (The request id was: 89b23bb50aecb477)
at In.handleRequestError (/var/task/node_modules/.prisma/client/runtime/library.js:122:6877)
at In.handleAndLogRequestError (/var/task/node_modules/.prisma/client/runtime/library.js:122:6211)
at In.request (/var/task/node_modules/.prisma/client/runtime/library.js:122:5919)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async l (/var/task/node_modules/.prisma/client/runtime/library.js:127:11167)
at async P (/var/task/apps/frontend/.next/server/chunks/7842.js:390:44)
at async p (/var/task/apps/frontend/.next/server/app/api/v1/offertargets/route.js:1:1615)
at async /var/task/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:34666
at async eS.execute (/var/task/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:25813)
at async eS.handle (/var/task/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:35920) {
code: 'P5000',
clientVersion: '5.14.0',
meta: undefined
}
PrismaClientKnownRequestError:
Invalid `prisma.$queryRawUnsafe()` invocation:
This request could not be understood by the server: {"type":"UnknownJsonError","body":{"code":"P6004","message":"The Query did not produce a result within the maximum allowed execution time of 10 seconds."}} (The request id was: 89b23bb50aecb477)
at In.handleRequestError (/var/task/node_modules/.prisma/client/runtime/library.js:122:6877)
at In.handleAndLogRequestError (/var/task/node_modules/.prisma/client/runtime/library.js:122:6211)
at In.request (/var/task/node_modules/.prisma/client/runtime/library.js:122:5919)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async l (/var/task/node_modules/.prisma/client/runtime/library.js:127:11167)
at async P (/var/task/apps/frontend/.next/server/chunks/7842.js:390:44)
at async p (/var/task/apps/frontend/.next/server/app/api/v1/offertargets/route.js:1:1615)
at async /var/task/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:34666
at async eS.execute (/var/task/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:25813)
at async eS.handle (/var/task/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:35920) {
code: 'P5000',
clientVersion: '5.14.0',
meta: undefined
}
2 replies
PPrisma
Created by Ted on 6/18/2024 in #help-and-questions
Accelerate migration not happening Vercel Prod but does with Vercel Preview
Vercel Preview migration just built and deployed just fine as expected, but Production build does not perform the migration! What? I have DIRECT_DATABASE_URLs specified for both. Using GCP Cloud SQL Postgres. URGENT.
2 replies
PPrisma
Created by Ted on 6/18/2024 in #help-and-questions
Prisma runtime error using direct db access in parallel with Accelerate on Vercel
I want to use two paths to Postgres: Prisma Accelerate and direct for a very limited use case (mentioned below) with my Next deployment. I get this runtime error on Vercel, not locally:
Error validating datasource `db`: the URL must start with the protocol `prisma://`
Error validating datasource `db`: the URL must start with the protocol `prisma://`
I export const prisma (for Accelerate) and prismaDirect (for direct access) as follows:
import {PrismaClient} from "@prisma/client"
import {withAccelerate} from "@prisma/extension-accelerate"

export const prisma = new PrismaClient({log: ['error']}).$extends(withAccelerate())

export const prismaDirect = new PrismaClient({datasourceUrl: process.env.DIRECT_DATABASE_URL})
import {PrismaClient} from "@prisma/client"
import {withAccelerate} from "@prisma/extension-accelerate"

export const prisma = new PrismaClient({log: ['error']}).$extends(withAccelerate())

export const prismaDirect = new PrismaClient({datasourceUrl: process.env.DIRECT_DATABASE_URL})
Relevant build output:
$ dotenv -e ../../.env -- npx prisma generate --no-engine
Prisma schema loaded from schema.prisma
✔ Generated Prisma Client (v5.14.0, engine=none) to ./../../node_modules/.prisma/client in 227ms
Start using Prisma Client in Node.js (See: https://pris.ly/d/client)
See other ways of importing Prisma Client: http://pris.ly/d/importing-client
Done in 1.69s.
yarn run v1.22.19
$ dotenv -e ../../.env -- npx prisma migrate deploy
Prisma schema loaded from schema.prisma
Datasource "db": PostgreSQL database "postgres", schema "public" at "XX.XX.XX.XX:5432"
32 migrations found in prisma/migrations
No pending migrations to apply.
$ dotenv -e ../../.env -- npx prisma generate --no-engine
Prisma schema loaded from schema.prisma
✔ Generated Prisma Client (v5.14.0, engine=none) to ./../../node_modules/.prisma/client in 227ms
Start using Prisma Client in Node.js (See: https://pris.ly/d/client)
See other ways of importing Prisma Client: http://pris.ly/d/importing-client
Done in 1.69s.
yarn run v1.22.19
$ dotenv -e ../../.env -- npx prisma migrate deploy
Prisma schema loaded from schema.prisma
Datasource "db": PostgreSQL database "postgres", schema "public" at "XX.XX.XX.XX:5432"
32 migrations found in prisma/migrations
No pending migrations to apply.
more in thread...
6 replies