Current behavior:
The deployed Serverless Function crashes immediately on any request with a
FUNCTION_INVOCATION_FAILED error. The logs only show Python process exited with exit status: 1 and
provide no Python traceback.
Expected behavior:
The FastAPI application should start correctly, connect to the database, and serve requests, just
as it does on my local machine.
he application uses FastAPI, SQLAlchemy, and connects to a Neon PostgreSQL database. The crash
seems to happen during the initial database connection attempt with SQLAlchemy’s create_engine.
api/index.py (relevant part):
1 from sqlalchemy import create_engine
2 from sqlalchemy.pool import NullPool # Also tried with pre-ping pool
3 import os
4
5 DATABASE_URL = os.getenv(“DATABASE_URL”)
6
7 # We have tried multiple configurations, including NullPool and pre-ping
8 db_engine = create_engine(
9 DATABASE_URL,
10 pool_pre_ping=True, # This was one of the attempted fixes
11 pool_recycle=300
12 ) if DATABASE_URL else None
13
14 # … rest of FastAPI app
requirements.txt:
1 fastapi==0.111.0
2 uvicorn==0.29.0
3 gunicorn==22.0.0
4 groq==0.9.0
5 python-dotenv==1.0.1
6 SQLAlchemy==2.0.30
7 psycopg2-binary==2.9.9
8 Jinja2==3.1.4
Framework: Python / FastAPI / SQLAlchemy
Database: Neon (PostgreSQL)
Project ID: prj_NYQoGb6XAAPCxUU98HN1WqMH1C7T
A recent failed invocation ID: tp5rh-1762855106666-e06ef947a54b
Crucially, I have already tried ALL of the following with no success:
Switching between Neon’s pooling and non-pooling connection URLs.
Using both psycopg2-binary and psycopg drivers.
Implementing both NullPool and pool_pre_ping=True for SQLAlchemy.
Pinning all dependency versions.
Using a vercel.json file.
Completely deleting and recreating the project on Vercel.
The issue seems to be a low-level runtime problem. Please help investigate the internal platform
logs. Thank you.
Vercel Staff
Hi , welcome to the Vercel Community!
I'm sorry that you are facing this issue. Did you confirm the environment variables are set up correctly in your Vercel project?
If you need more help, please share your public repo or a minimal reproducible example. That will let us all work together from the same code to figure out what’s going wrong.
I was able to get a FastAPI project working using our template:
As I mentioned in my original post, we have already tried all the standard solutions (switching
pooling modes, changing drivers, pinning Python version, etc.) without success. The application
continues to crash with exit status 1 and no Python traceback.
Could you please escalate this and have someone look at the internal platform logs for the project?
Project ID: prj_NYQoGb6XAAPCxUU98HN1WqMH1C7T
Thank you.
Vercel Staff
Thanks for the additional information. Let me try to recreate the issue.
On a side note, based on the readme it looks like you're trying to use Vercel as a proxy to bypass regional blocking for Groq. Have you tried using https://vercel.com/docs/ai/groq? It might be simpler.
Thanks for looking into it.
Regarding the Groq proxy, you are right. I wasn’t aware of the official Vercel Groq Integration
when I started. I will definitely look into refactoring to use it once the main database connection
issue is resolved.
My primary concern right now is indeed the exit status 1 crash related to the database connection.
I’m looking forward to hearing what you find when you try to reproduce it.
Thank you!
Vercel Staff
Just wanted to share that by using Vercel AI Gateway you don't need to make your own proxy to bypass the regional blocking.
You should be able to get some information from the logs.
Vercel Alum
Hey! We're running this session next week after our recent announcement of Gel joining the team. Because you had posted about Python, I thought I'd give you a heads up in case you wanted to join us! :D