I am having trouble with “server has closed the connection.” Prisma does not perform a connection health check after creating a connection, right? If the socket is closed due to TCP Idle Timeout in the network configuration or OS, rather than in the application or Prisma client, Prisma client will continue to hold the connection.
As a result, an error “server has closed the connection” occurs when executing a query, and the query cannot be executed.
sequenceDiagram participant pc as Prisma Client participant cr as Cloud Run participant ds as DB Server pc ->> cr: Execute connect() cr ->> ds: Establish TCP connection Note over pc,ds: Connection is established, but remains idle afterward pc ->> pc: Idle state (for a long period) Note over ds: DB server has no idle timeout ds -->> ds: Periodically sends TCP Keepalive ds ->> cr: TCP Keepalive check cr -->> cr: ⚠️ No response (connection was already dropped due to idleness) ds ->> cr: No Keepalive response → assumes disconnection ds -->> ds: ⛔ Marks as "Connection reset by peer" ds ->> cr: Closes the connection pc ->> ds: Sends a delayed query (SELECT * FROM ..) ds -->> pc: ⛔ Error response: "Server has closed the connection"
sequenceDiagram participant pc as Prisma Client participant cr as Cloud Run participant ds as DB Server pc ->> cr: Execute connect() cr ->> ds: Establish TCP connection Note over pc,ds: Connection is established, but remains idle afterward pc ->> pc: Idle state (for a long period) Note over ds: DB server has no idle timeout ds -->> ds: Periodically sends TCP Keepalive ds ->> cr: TCP Keepalive check cr -->> cr: ⚠️ No response (connection was already dropped due to idleness) ds ->> cr: No Keepalive response → assumes disconnection ds -->> ds: ⛔ Marks as "Connection reset by peer" ds ->> cr: Closes the connection pc ->> ds: Sends a delayed query (SELECT * FROM ..) ds -->> pc: ⛔ Error response: "Server has closed the connection"
Problem I need to check if the app is still connected to the DB. The solution must be universal for every database. Suggested solution Enable the "provider" field as a public (or getProvi...
Question Possibly related to this issue, but I'm confused as to how applications are supposed to gracefully handle transient DB connection errors due to things like database/pgbouncer restarts....