From 81ee9bdb465bbe760333a655d39afbb47cf46824 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 11 Nov 2025 05:26:14 +0000 Subject: [PATCH] Fix Vercel deployment hanging issue Added directUrl configuration to Prisma schema and created vercel.json with extended timeout settings to resolve deployment hangs after database check. Includes comprehensive deployment guide for Supabase setup. --- VERCEL_DEPLOYMENT.md | 109 +++++++++++++++++++++++++++++++++++++++++++ prisma/schema.prisma | 1 + vercel.json | 8 ++++ 3 files changed, 118 insertions(+) create mode 100644 VERCEL_DEPLOYMENT.md create mode 100644 vercel.json diff --git a/VERCEL_DEPLOYMENT.md b/VERCEL_DEPLOYMENT.md new file mode 100644 index 00000000..4efd95f7 --- /dev/null +++ b/VERCEL_DEPLOYMENT.md @@ -0,0 +1,109 @@ +# Vercel Deployment Guide for Umami + +This guide will help you successfully deploy Umami on Vercel, especially if you're experiencing the "Database version check successful" hang issue. + +## Required Environment Variables + +### For Supabase Users + +You need to configure **TWO** database URLs in your Vercel environment variables: + +#### 1. DATABASE_URL (Connection Pooler) +This URL uses pgbouncer for connection pooling. + +**Format:** +``` +DATABASE_URL=postgresql://user:password@host.pooler.supabase.com:6543/postgres?pgbouncer=true&connect_timeout=15 +``` + +**Important notes:** +- Use port `6543` (pgbouncer port) +- Include `?pgbouncer=true&connect_timeout=15` parameters +- Host should end with `.pooler.supabase.com` + +#### 2. DIRECT_DATABASE_URL (Direct Connection) +This URL connects directly to the database, bypassing pgbouncer. + +**Format:** +``` +DIRECT_DATABASE_URL=postgresql://user:password@host.supabase.com:5432/postgres +``` + +**Important notes:** +- Use port `5432` (direct postgres port) +- Do **NOT** include pgbouncer parameters +- Host should end with `.supabase.com` (without `.pooler`) + +### For Other PostgreSQL Providers + +If you're not using Supabase, you still need both environment variables: + +``` +DATABASE_URL=postgresql://username:password@host:port/database +DIRECT_DATABASE_URL=postgresql://username:password@host:port/database +``` + +For non-pooled connections, both can be the same URL. + +## Additional Environment Variables + +Make sure you also have: +``` +APP_SECRET=your-random-secret-key +``` + +## Vercel Configuration + +The `vercel.json` file has been configured with: +- **Function timeout**: 300 seconds (5 minutes) to prevent build timeouts +- **Custom build command**: Ensures database migrations run before the build + +## Troubleshooting + +### Build Still Hanging? + +1. **Check Database Connectivity**: Ensure your database is accessible from Vercel's network +2. **Verify Environment Variables**: Double-check both `DATABASE_URL` and `DIRECT_DATABASE_URL` are set correctly +3. **Check Password Encoding**: Special characters in passwords may need URL encoding +4. **Review Vercel Logs**: Look for errors after the "Database version check successful" message + +### Migration Issues + +If you have pending migrations that are causing issues, run locally: + +```bash +npx prisma migrate resolve --applied "migration_name" +npx prisma migrate deploy +``` + +Then redeploy to Vercel. + +### Common Mistakes + +- ❌ Using the same port (6543) for both URLs +- ❌ Missing pgbouncer parameters on DATABASE_URL +- ❌ Including pgbouncer parameters on DIRECT_DATABASE_URL +- ❌ Not URL-encoding special characters in passwords +- ❌ Using `.pooler.supabase.com` for DIRECT_DATABASE_URL + +### Port Reference for Supabase + +| Connection Type | Port | Host Pattern | URL Parameter | +|----------------|------|--------------|---------------| +| Pooled (DATABASE_URL) | 6543 | `*.pooler.supabase.com` | `?pgbouncer=true&connect_timeout=15` | +| Direct (DIRECT_DATABASE_URL) | 5432 | `*.supabase.com` | None | + +## Deployment Steps + +1. Set up both environment variables in Vercel dashboard +2. Push your code changes (including the updated `schema.prisma` and `vercel.json`) +3. Trigger a new deployment +4. Monitor the build logs + +## Need Help? + +If you're still experiencing issues: +- Check Vercel's deployment logs for specific errors +- Verify your database is accepting connections +- Ensure your database user has the correct permissions +- Try connecting to your database using a PostgreSQL client to verify credentials diff --git a/prisma/schema.prisma b/prisma/schema.prisma index aeb11648..fd520760 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -7,6 +7,7 @@ generator client { datasource db { provider = "postgresql" url = env("DATABASE_URL") + directUrl = env("DIRECT_DATABASE_URL") relationMode = "prisma" } diff --git a/vercel.json b/vercel.json new file mode 100644 index 00000000..1fe5c8f5 --- /dev/null +++ b/vercel.json @@ -0,0 +1,8 @@ +{ + "functions": { + "api/**/*.js": { + "maxDuration": 300 + } + }, + "buildCommand": "npm run build-db && npm run build" +}