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

Commit fa70236

Browse files
committed
allow disconnect on timeout to be disabled
1 parent 398942c commit fa70236

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

initializers/transaction.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
/*jslint unparam: true */
1010

11-
var CONN_TIMEOUT = 5000;
12-
var DISCONN_TIMEOUT = 5000;
11+
var CONN_TIMEOUT = process.env.CONN_TIMEOUT || 5000;
12+
var DISCONNECT_ON_CONN_TIMEOUT = process.env.DISCONNECT_ON_CONN_TIMEOUT !== "false" ? true : false;
13+
var DISCONN_TIMEOUT = process.env.DISCONN_TIMEOUT || 5000;
1314

1415
var handleConnectionFailure = function (api, connection, actionTemplate, error, next) {
1516
api.log("Close all opened connections", "debug");
@@ -63,7 +64,9 @@ exports.transaction = function (api, next) {
6364

6465
var connectTimeout = function() {
6566
api.log("Timed out without obtaining all DB connections", "error");
66-
handleConnectionFailure(api, connection, actionTemplate, "Open Timeout", next);
67+
if (DISCONNECT_ON_CONN_TIMEOUT) {
68+
handleConnectionFailure(api, connection, actionTemplate, "Open Timeout", next);
69+
}
6770
}
6871

6972
var clearMe = setTimeout(connectTimeout, CONN_TIMEOUT);

0 commit comments

Comments
 (0)