New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prisma does not recover from PrismaClientInitializationError #9420
Comments
When I drop the connection in runtime, it throws So the issue is only about the first connection attempt. |
Hi folks, we're experiencing this issue too. Is there any update on this bug? Is there a way to work around it in the meantime (other than restarting the application)? |
Hi, we are experiencing this issue too. For now, we are creating a new instance of PrismaClient when having an error on the first connect. I don't know if it's the best solution, but it solve our problem for now. let prisma = new PrismaClient();
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
(async () => {
while (true) {
try {
await prisma.$connect();
break;
} catch {
await sleep(1000);
prisma = new PrismaClient();
}
}
})(); |
I am also experiencing this error. Additionally no error is logged when used with |
#12066 fixes this. You can test it out with |
This appears to have regressed at least in >= 4.10.0: |
Bug description
When the database is not available on startup, calling
prisma.$connect()
throwPrismaClientInitializationError
.However, when the database becomes available, all the repetive calls of
prisma.$connect()
or normal Prisma Client queries fails with the samePrismaClientInitializationError
.How to reproduce
prisma.$connect()
every e.g. 10 seconds.PrismaClientInitializationError
PrismaClientInitializationError
.Expected behavior
It should try to reconnect instead of throwing
PrismaClientInitializationError
when the database becomes available.Prisma information
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: