File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22import { config } from "dotenv" ;
33import { defineConfig , env } from "prisma/config" ;
44
5- config ( { path : ".env.local" } ) ;
6- config ( ) ;
5+ if ( ! process . env . VERCEL ) {
6+ config ( { path : ".env.local" } ) ;
7+ config ( ) ;
8+ }
79
810const prismaCliDatabaseUrl = process . env . DIRECT_URL ?? process . env . DATABASE_URL ;
911
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ const RETRY_DELAY_MS = Number.parseInt(process.env.PRISMA_DEPLOY_RETRY_DELAY_MS
55
66const advisoryLockTimeoutPattern =
77 / P 1 0 0 2 | T i m e d o u t t r y i n g t o a c q u i r e a p o s t g r e s a d v i s o r y l o c k / i;
8+ const transientConnectionPattern =
9+ / P 1 0 0 1 | C a n ' t r e a c h d a t a b a s e s e r v e r | E C O N N R E S E T | E C O N N R E F U S E D | E T I M E D O U T | E N O T F O U N D / i;
810
911const sleep = ( ms ) => new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
1012
@@ -28,15 +30,20 @@ for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt += 1) {
2830
2931 const combinedOutput = `${ result . stdout ?? "" } \n${ result . stderr ?? "" } ` ;
3032 const isAdvisoryLockTimeout = advisoryLockTimeoutPattern . test ( combinedOutput ) ;
31- const shouldRetry = isAdvisoryLockTimeout && attempt < MAX_ATTEMPTS ;
33+ const isTransientConnectionError = transientConnectionPattern . test ( combinedOutput ) ;
34+ const shouldRetry =
35+ ( isAdvisoryLockTimeout || isTransientConnectionError ) && attempt < MAX_ATTEMPTS ;
3236
3337 if ( ! shouldRetry ) {
3438 process . exit ( result . status ?? 1 ) ;
3539 }
3640
3741 const waitSeconds = Math . ceil ( RETRY_DELAY_MS / 1000 ) ;
42+ const reason = isAdvisoryLockTimeout
43+ ? "advisory lock timeout"
44+ : "temporary database connectivity issue" ;
3845 console . warn (
39- `[prisma:deploy] Advisory lock timeout detected (attempt ${ attempt } /${ MAX_ATTEMPTS } ). Retrying in ${ waitSeconds } s...` ,
46+ `[prisma:deploy] ${ reason } detected (attempt ${ attempt } /${ MAX_ATTEMPTS } ). Retrying in ${ waitSeconds } s...` ,
4047 ) ;
4148 await sleep ( RETRY_DELAY_MS ) ;
4249}
You can’t perform that action at this time.
0 commit comments