-
-
Notifications
You must be signed in to change notification settings - Fork 150
Open
Labels
Description
I noticed that if the connection handler throws any error, the connection itself is destroyed:
slonik/packages/slonik/src/factories/createConnection.ts
Lines 185 to 196 in 35543e1
| try { | |
| result = await connectionHandler( | |
| connectionLog, | |
| connection, | |
| boundConnection, | |
| clientConfiguration, | |
| ); | |
| } catch (error) { | |
| await connection.destroy(); | |
| throw error; | |
| } |
Is this really necessary? It feels wrong when:
- If we are simply throwing an error to indicate an application logic, that connection must destroyed and recreated.
- If we are doing a transaction and want to rollback, that connection must be destroyed and recreated.
Shouldn't we only destroy the connection when there is some underlying issue?