Skip to content

Commit 69627a1

Browse files
author
zetxx
committed
fix: tx end,begin errors
1 parent adefa7b commit 69627a1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/postgres/index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ module.exports = async(
172172
txMap.set(id, client);
173173
return id;
174174
} catch (e) {
175-
log('error', `TX Begin: id: ${id}`, e);
175+
log('error', `fail while TX Begin: id: ${id}`);
176+
log('error', e);
176177
throw e;
177178
}
178179
},
@@ -185,11 +186,13 @@ module.exports = async(
185186
async txEnd(id, action) {
186187
try {
187188
const client = txMap.get(id);
189+
if (!client) {throw new Error('NoSuchTxId');}
188190
await client.query(action);
189191
client.release();
190192
txMap.delete(id);
191193
} catch (e) {
192-
log('error', `TX End: id: ${id}`, e);
194+
log('error', `fail while try to end tx id ${id}`);
195+
log('error', e);
193196
throw e;
194197
}
195198
}

0 commit comments

Comments
 (0)