Skip to content

Commit 69f673e

Browse files
authored
Disallow transaction to return a Promise due to unexpected behaviour (WiseLibs#1364)
disallow transaction to return a promise due to unexpected behaviour
1 parent 3d7e671 commit 69f673e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/methods/transaction.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ const wrapTransaction = (apply, fn, db, { begin, commit, rollback, savepoint, re
6363
before.run();
6464
try {
6565
const result = apply.call(fn, this, arguments);
66+
if (result && typeof result.then === 'function') {
67+
throw new TypeError('Transaction function cannot return a promise');
68+
}
6669
after.run();
6770
return result;
6871
} catch (ex) {

0 commit comments

Comments
 (0)