Hi. Q: Started seeing this sometimes, not sure if ...
# prisma-client
m
Hi. Q: Started seeing this sometimes, not sure if something has changed in prisma recently that this error wouldnt be handled?
Copy code
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: Can't reach database server at `my-host-here`:`5432`
Please make sure your database server is running at `my-host-here`:`5432`.
    at LineStream.<anonymous> (/app/node_modules/@prisma/client/runtime/index.js:27666:31)...
Prisma client 2.25.0 // Any advice how I should handle this? Using it in the context of nestjs? is there a way to configure a retry with prisma client?
r
@Mitchell Amihod šŸ‘‹ This seems like a bug. It would be great if you could open an issue with all the necessary details so that we can look into this šŸ™‚
j
This actually looks rather boring - as in your database really just does not want to answer at that host + port.
Did this really just change with the update? Nothing else changed?
If yes, then indeed an issue would be nice but I can already tell you this will be hard to reproduce - so include all the info the bug template asks for please.
m
yeah, i will look more at it. i know the db is there and ready. it just not ready when the first connect attempts, and then it just hangs
i can confirm, because i am able to connect, and when i do another deployment (which rolls the pod, restarting the app) then all is good. its just a race on first deployment because the db is coming up as well. but ideally, there would be a way to handle this so it doesnt just hang my app.
@janpio re:
Did this really just change with the update? Nothing else changed?
not sure - i can try downgrading to 2.23 and see if it persists.
i mean, in this case its the unhandled error, so wondering if my connect call need to be wrapped in a try? and then thats why i was asking about if there is a retry mechanism
j
Yes, that is how one would expect to handle flaky errors like this in general.
Prisma can not differentiate between "there is no database server" and "the database server is spotty as it just has been started".
m
right. i ’m not asking it to guess. I was just asking if there is a connect retry mechanism to use (which is a totally normal thing to bake into a client) before rolling my own
i guess the bigger issue i’m having is it just seems to hang my app, rather than crash it - but maybe thats just the nature of an unhandled rejection? (not claiming to be a Promises expert, so thats why i’m feeling my way around here to see what the solution might be).
r
For now I guess you could use something like this with
prisma.$connect()
with a retry interval as a workaround.
m
yeah, i will thanks!
šŸ‘ 1