Return the results from withResource function before applying the respond continuation. This ensures that the pool resource is freed as soon as the database operation is complete
This commit is contained in:
@@ -97,8 +97,9 @@ main = do
|
|||||||
body <- strictRequestBody req
|
body <- strictRequestBody req
|
||||||
let handleReq = H.run $ inTransaction ReadCommitted
|
let handleReq = H.run $ inTransaction ReadCommitted
|
||||||
(runWithClaims conf time (app dbStructure conf body) req)
|
(runWithClaims conf time (app dbStructure conf body) req)
|
||||||
withResource pool $ \case
|
res <- withResource pool $ \case
|
||||||
Left err -> respond $ errResponse HT.status500 (cs . show $ err)
|
Left err -> return $ errResponse HT.status500 (cs . show $ err)
|
||||||
Right c -> do
|
Right c -> do
|
||||||
resOrError <- handleReq c
|
resOrError <- handleReq c
|
||||||
either (respond . pgErrResponse) respond resOrError
|
either (return . pgErrResponse) return resOrError
|
||||||
|
respond res
|
||||||
|
|||||||
Reference in New Issue
Block a user