Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit d0f3ea3

Browse files
only close the connection if it's new when fetching payments
1 parent 0881712 commit d0f3ea3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/services/paymentService.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ async function prepare(connection, sql) {
5353
}
5454

5555
async function paymentExists(payment, connection) {
56-
if (!connection) connection = await helper.getInformixConnection()
56+
let isNewConn = false
57+
if (!connection) {
58+
connection = await helper.getInformixConnection()
59+
isNewConn = true
60+
}
5761
try {
5862
const query = util.format(QUERY_PAYMENT, payment.memberId, payment.v5ChallengeId, payment.typeId)
5963
logger.debug(`Checking if paymentExists - ${query}`)
@@ -62,7 +66,7 @@ async function paymentExists(payment, connection) {
6266
logger.error(`Error in 'paymentExists' ${e}`)
6367
throw e
6468
} finally {
65-
if (!connection) await connection.closeAsync()
69+
if (isNewConn) await connection.closeAsync()
6670
}
6771
}
6872

0 commit comments

Comments
 (0)