tursodatabase / tursodatabase/libsql-client-ts
Socket hangup when building site on vercel with nextjs
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 576
- Forks
- 69
- PR merge metrics
- No merged PRs in 30d
Description
Sometimes when I build the site Prisma throws a socket hangup error. It also happens locally time to time, and if I hard refresh it goes away.
Error:
Packages:
"@libsql/client": "^0.4.3",
"@prisma/adapter-libsql": "^5.18.0",
"prisma": "^5.18.0",
"@prisma/client": "^5.18.0",
I'm creating the connection like this:
import { createClient } from '@libsql/client'
import { PrismaLibSQL } from '@prisma/adapter-libsql'
import { PrismaClient } from '@prisma/client'
declare global {
// eslint-disable-next-line no-var
var cachedPrisma: PrismaClient
}
let prisma: PrismaClient
if (process.env.NODE_ENV === 'production') {
const libsql = createClient({
url: `${process.env.TURSO_DATABASE_URL}`,
authToken: `${process.env.TURSO_AUTH_TOKEN}`,
})
const adapter = new PrismaLibSQL(libsql)
prisma = new PrismaClient({ adapter })
} else {
if (!global.cachedPrisma) {
const libsql = createClient({
url: `${process.env.TURSO_DATABASE_URL}`,
authToken: `${process.env.TURSO_AUTH_TOKEN}`,
})
const adapter = new PrismaLibSQL(libsql)
global.cachedPrisma = new PrismaClient({ adapter })
}
prisma = global.cachedPrisma
}
export const db = prisma
and then using db like this in my code:
const tableName = await db.tableName.findMany({ })
Is there something I can do to prevent this? Maybe I'm not doing the connection correctly.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the socket hangup locally and on Vercel using the connection setup and package versions shown in the issue. Trace the reported error through the Next.js build and database connection, then verify that the identified configuration or client behavior no longer causes failed builds or intermittent requests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, sqlite, typescript
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100