Skip to content

Commit d0c15a2

Browse files
committed
fix: protect transaction rollback so mirror rollback is always reached
If transaction.rollback() throws, mirrorTransaction.rollback() was never reached, leaking the mirror connection. Wrap both rollbacks in independent try-catch blocks.
1 parent 38db571 commit d0c15a2

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/tasks/sync-registries.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,15 @@ async function createAndProcessTransaction(callback, afterCommitCallbacks) {
253253

254254
return true;
255255
} catch (error) {
256-
// Roll back the transaction if an error occurs
256+
logger.error(
257+
`encountered error syncing organization audit. Rolling back transaction. Error: ${error}`,
258+
);
257259
if (transaction) {
258-
logger.error(
259-
`encountered error syncing organization audit. Rolling back transaction. Error: ${error}`,
260-
);
261-
await transaction.rollback();
260+
try {
261+
await transaction.rollback();
262+
} catch (rollbackErr) {
263+
logger.error(`transaction rollback failed: ${rollbackErr.message}`);
264+
}
262265
}
263266
if (mirrorTransaction) {
264267
try {

0 commit comments

Comments
 (0)