From aac6796d8c97dc56a14befad69f73e0ab33c1c69 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 20 Feb 2026 09:10:36 +0000 Subject: [PATCH] Wrap migration ROLLBACK in try/catch to preserve original error Match the pattern used in StateDb.transaction: if ROLLBACK itself throws (e.g. bad DB connection state), the original migration error is still re-thrown instead of being replaced by the rollback error. --- apps/server/src/stateMigrations.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/server/src/stateMigrations.ts b/apps/server/src/stateMigrations.ts index 9a2e11b8d0..f483dbae91 100644 --- a/apps/server/src/stateMigrations.ts +++ b/apps/server/src/stateMigrations.ts @@ -90,7 +90,11 @@ export function runStateMigrations(db: SqliteDatabase): void { db.exec(`PRAGMA user_version=${STATE_DB_SCHEMA_VERSION};`); db.exec("COMMIT;"); } catch (error) { - db.exec("ROLLBACK;"); + try { + db.exec("ROLLBACK;"); + } catch { + // Preserve the original migration error if rollback also throws. + } throw error; } }