From f93f998e6b4226fcc4529d74fd866b2cc1e410f1 Mon Sep 17 00:00:00 2001 From: pawelblaszczyk5 Date: Fri, 5 Jan 2024 12:11:30 +0100 Subject: [PATCH] Optimize waking up --- prisma/deploy.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/prisma/deploy.ts b/prisma/deploy.ts index cbc2ca6..a098d3f 100644 --- a/prisma/deploy.ts +++ b/prisma/deploy.ts @@ -13,11 +13,11 @@ if (!DATABASE_PUBLIC_URL) { throw new Error('DATABASE_PUBLIC_URL must be defined for waking up db'); } -const tryWakingUpDatabase = async () => { +const tryWakingUpDatabase = () => { console.log('Trying to wake up database via public URL'); try { - await new PrismaClient({ datasources: { db: { url: DATABASE_PUBLIC_URL } } }).$connect(); + new PrismaClient({ datasources: { db: { url: DATABASE_PUBLIC_URL } } }).$connect(); } catch { /* empty */ } @@ -38,8 +38,6 @@ const deployPrismaMigrationsWithRetrying = () => { if (!isDatabaseUnavailable) throw error; - await tryWakingUpDatabase(); - const delayMs = BASE_DELAY * 2 ** currentRetry; currentRetry += 1; @@ -56,4 +54,5 @@ const deployPrismaMigrationsWithRetrying = () => { return execute(); }; +tryWakingUpDatabase(); await deployPrismaMigrationsWithRetrying();