From 114f62a524194634b474c9835710d409aa644a5f Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 21 Feb 2026 09:20:03 -0800 Subject: [PATCH] Fix #1612: await migrateDb promise and rethrow unhandled errors migrateDb() was not awaiting the runMigrate() promise chain, causing migrations to fire-and-forget. The caller (instrumentation.node.ts) would receive a resolved promise immediately, log "Migrations run successfully!" before any migration ran, and the app would start serving requests against a stale schema. Additionally, the second .catch() silently swallowed non-orgId errors, hiding migration failures entirely. Both issues are fixed: the chain is now awaited and unhandled errors are re-thrown. Co-Authored-By: Claude Sonnet 4.6 --- packages/database/migrate.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/database/migrate.ts b/packages/database/migrate.ts index de41fdc56d..bd1ce0de9a 100644 --- a/packages/database/migrate.ts +++ b/packages/database/migrate.ts @@ -20,7 +20,7 @@ function errorIsOrgIdMigration(e: unknown): e is DrizzleQueryError { } export async function migrateDb() { - runMigrate() + await runMigrate() .catch(async (e) => { if (errorIsOrgIdMigration(e)) { console.log("non-null videos.orgId migration failed, running backfill"); @@ -34,5 +34,6 @@ export async function migrateDb() { throw new Error( "videos.orgId backfill failed, you will need to manually update the videos.orgId column before attempting to migrate again.", ); + throw e; }); }