1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

fix: rollback should await a result (#7712)

This commit is contained in:
Mateusz Kwasniewski 2024-07-31 16:46:15 +02:00 committed by GitHub
parent 49fecb2005
commit a4c49e7d7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -93,10 +93,11 @@ export function withRollback<S>(
const service = serviceFactory(db) as WithRollback<S>;
service.rollback = async <R>(fn: (service: S) => R) => {
const trx = await db.transaction({ isolationLevel: 'serializable' });
const trx = await db.transaction();
try {
const transactionService = serviceFactory(trx);
return fn(transactionService);
const result = await fn(transactionService);
return result;
} finally {
await trx.rollback();
}