From 42850ea17c330e37e22c254981f2c3c4552824e8 Mon Sep 17 00:00:00 2001 From: denshooter Date: Wed, 4 Mar 2026 14:38:59 +0100 Subject: [PATCH] fix: prevent crash loop when database is unreachable Make prisma migrate deploy failure non-fatal in start-with-migrate.js. Previously, migration failure caused process.exit() which killed the container, triggering an infinite restart loop. Now logs a warning and starts the Next.js server anyway (app has DB fallbacks). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- scripts/start-with-migrate.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/start-with-migrate.js b/scripts/start-with-migrate.js index e10f5fd..89195ed 100644 --- a/scripts/start-with-migrate.js +++ b/scripts/start-with-migrate.js @@ -134,7 +134,17 @@ async function main() { // If baseline fails we continue to migrate deploy, which will surface the real issue. } } - run("node", ["node_modules/prisma/build/index.js", "migrate", "deploy"]); + + const migrateResult = spawnSync( + "node", + ["node_modules/prisma/build/index.js", "migrate", "deploy"], + { stdio: "inherit", env: process.env } + ); + if (migrateResult.status !== 0) { + console.error( + `[startup] prisma migrate deploy failed (exit ${migrateResult.status}). Starting server anyway...` + ); + } } else { console.log("SKIP_PRISMA_MIGRATE=true -> skipping prisma migrate deploy"); }