Prisma Not Working - NextJs
Unanswered
Yellow-throated Vireo posted this in #help-forum
Yellow-throated VireoOP
Hey all! Having a gnarly issue. TLDR Prisma not connecting to the db in Github Actions NextJs getStaticProps
Prisma client code:
NextJs getStaticProps that is failing
Here's the logs in localhost:
Here's the logs in github actions
Prisma client code:
const DATABASE_PGBOUNCER_URL = "postgresql://postgres:***@db.***.supabase.co:6543/postgres?pgbouncer=true&connection_limit=1&pool_timeout=30
const prisma = new PrismaClient({
log: ['query', 'info', 'warn', 'error'],
datasources: {
db: {
url: process.env.DATABASE_PGBOUNCER_URL,
},
},
})NextJs getStaticProps that is failing
export const getStaticProps: GetStaticProps = async () => {
console.log('A')
const xyz = await fetch('https://www.google.com/')
console.log({ B: xyz.status })
console.log('C')
try {
await prisma.$queryRaw`SELECT 1`
} catch (err) {
console.error(err)
}
console.log('D')
}Here's the logs in localhost:
A
{ B: 200 }
C
> prisma:info Starting a postgresql pool with 1 connections in PgBouncer mode.
> prisma:query BEGIN
> prisma:query DEALLOCATE ALL
> prisma:query SELECT 1
> prisma:query COMMIT
DHere's the logs in github actions
A
{ B: 200 }
C
> prisma:info Starting a postgresql pool with 1 connections in PgBouncer mode.
Static worker unexpectedly exited with code: null and signal: SIGSEGV
> Build error occurred
Error: Static page generation for / is still timing out after 3 attempts. See more info here
https://nextjs.org/docs/messages/static-page-generation-timeout21 Replies
Bigeye tuna
Prisma client code:
const prisma = new PrismaClient({
log: ['query', 'info', 'warn', 'error'],
datasources: {
db: {
url: process.env.NEXT_PUBLIC_DATABASE_PGBOUNCER_URL,
},
},
const prisma = new PrismaClient({
log: ['query', 'info', 'warn', 'error'],
datasources: {
db: {
url: process.env.NEXT_PUBLIC_DATABASE_PGBOUNCER_URL,
},
},
Yellow-throated VireoOP
Nope. This is run from the backend so
NEXT_PUBLIC_ isn't necessary@Yellow-throated Vireo Hey all! Having a gnarly issue. TLDR Prisma not connecting to the db in Github Actions NextJs getStaticProps
Prisma client code:
const DATABASE_PGBOUNCER_URL = "postgresql://postgres:***@db.***.supabase.co:6543/postgres?pgbouncer=true&connection_limit=1&pool_timeout=30
const prisma = new PrismaClient({
log: ['query', 'info', 'warn', 'error'],
datasources: {
db: {
url: process.env.DATABASE_PGBOUNCER_URL,
},
},
})
NextJs getStaticProps that is failing
export const getStaticProps: GetStaticProps = async () => {
console.log('A')
const xyz = await fetch('https://www.google.com/')
console.log({ B: xyz.status })
console.log('C')
try {
await prisma.$queryRaw`SELECT 1`
} catch (err) {
console.error(err)
}
console.log('D')
}
Here's the logs in localhost:
A
{ B: 200 }
C
> prisma:info Starting a postgresql pool with 1 connections in PgBouncer mode.
> prisma:query BEGIN
> prisma:query DEALLOCATE ALL
> prisma:query SELECT 1
> prisma:query COMMIT
D
Here's the logs in github actions
A
{ B: 200 }
C
> prisma:info Starting a postgresql pool with 1 connections in PgBouncer mode.
Static worker unexpectedly exited with code: null and signal: SIGSEGV
> Build error occurred
Error: Static page generation for / is still timing out after 3 attempts. See more info here
https://nextjs.org/docs/messages/static-page-generation-timeout
have you tried the suggestions here? https://github.com/vercel/next.js/discussions/48192
Yellow-throated VireoOP
This is super helpful @joulev! Will update here if resolved
You can also just run the init command for Prisma and it will generate what it's needed, you just edit what it's for and it does the rest! Took me like under 20 minutes to get mysql working with it!
Yellow-throated VireoOP
@SkippTekk can you explain what you mean by this? Do you mean the prisma cli or something in-line in js/ts code?
@Yellow-throated Vireo <@267920707248193537> can you explain what you mean by this? Do you mean the prisma cli or something in-line in js/ts code?
So with prisma. What I did was basically this.
npx prisma init i think
Adjusted the add-ons (or created) in .env
Once it had the proper info, edit the schema file in the folder prisma
And once that's adjusted. I ran prisma db pull and it just created the right file. And the final was prisma generate I'm going off memory
npx prisma init i think
Adjusted the add-ons (or created) in .env
Once it had the proper info, edit the schema file in the folder prisma
And once that's adjusted. I ran prisma db pull and it just created the right file. And the final was prisma generate I'm going off memory
Yellow-throated VireoOP
Still having this issue. Tried solutions in the thread but no dice
@Yellow-throated Vireo did you get it working?
Yellow-throated VireoOP
@SkippTekk Still struggling a bit here
One solution I found is that if I upgrade my prisma version (am using
One solution I found is that if I upgrade my prisma version (am using
4.10.1, upgraded to 5.1.1) then the problem goes away. Now dealing with some new problems regarding this upgradeAppreciate the check in 🙂
is it prisma related or did you get that resolved
Yellow-throated VireoOP
Unclear
err?
Yellow-throated VireoOP
Prisma version fixes it so maybe prisma related
But maybe something underlying in nextjs
can you throw the error?
kinda hard to help with no information 😛
Yellow-throated VireoOP
It's this error:
Static worker unexpectedly exited with code: null and signal: SIGSEGV. Error: Static page generation for / is still timing out after 3 attempts.that one doesn't help either.... xD
is there a full length to it? does it happen on certain parts? what page does it happen on?