prisma.$connect() not invoking error on turned off database #8154
Labels
bug/0-unknown
Bug is new, does not have information for reproduction or reproduction could not be confirmed.
kind/bug
A reported bug.
topic: mongodb
Bug description
In the case of a failed connection, prisma should be calling the error PrismaClientInitializationError. Using the following code to connect:
the line,
await prisma.$connect()
should throw an error when theDATABASE_URL
environment is unconnectable or unreachable. However, it does not.Though, it throws an error when a query is called:
ConnectorError(ConnectorError { user_facing_error: None, kind: RawError { code: "unknown", message: "Server selection timeout: No available servers. Topology: { Type: Unknown, Servers: [ { Address: localhost:27017, Type: Unknown, Error: No connection could be made because the target machine actively refused it. (os error 10061) }, ] }" } })
Possible related issue/s: #6431
How to reproduce
connecttodb()
Expected behavior
It's expected for prisma to throw the error PrismaClientInitializationError. According to the documentation, it should be invoked if something goes wrong when the query engine is started and the connection to the database is created.
This happens either:
If i'm getting anything wrong in regards to the "query engine is started and the connection to the database is created". Feel free to correct me. Though, it's still best that the error should be called on connection initialization to prevent further errors in production.
Prisma information
Connection code:
Prisma schema:
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: