dborm-mysql 2.2.2 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base/db.js +4 -1
- package/package.json +1 -1
package/base/db.js
CHANGED
|
@@ -74,22 +74,25 @@ module.exports = (dbConfig, {log, noConvertDbCodes, dbCode, logExecuteTime, logg
|
|
|
74
74
|
|
|
75
75
|
let conn = yield db.beginTransaction(newOptions);
|
|
76
76
|
let result;
|
|
77
|
+
let timer;
|
|
77
78
|
try {
|
|
78
79
|
params[nth] = conn;
|
|
79
80
|
result = yield Promise.race([
|
|
80
81
|
fn.apply(ctx, params),
|
|
81
82
|
new Promise((res) => {
|
|
82
|
-
setTimeout(() => {
|
|
83
|
+
timer = setTimeout(() => {
|
|
83
84
|
res(Message);
|
|
84
85
|
}, timeout || 50000);
|
|
85
86
|
})
|
|
86
87
|
]);
|
|
88
|
+
if(timer) clearTimeout(timer);
|
|
87
89
|
if(result === Message){
|
|
88
90
|
throw new Error(result);
|
|
89
91
|
}
|
|
90
92
|
yield db.commitTransaction(conn);
|
|
91
93
|
conn.release();
|
|
92
94
|
} catch (err) {
|
|
95
|
+
if(timer) clearTimeout(timer);
|
|
93
96
|
yield db.rollbackTransaction(conn);
|
|
94
97
|
conn.release();
|
|
95
98
|
conn.destroy();
|