FastAPI Lifespan Events are now supported on Vercel
By Steven Van ·
FastAPI apps on Vercel can now run startup and shutdown logic, though shutdown cleanup is capped at 500ms.
FastAPI apps deployed on Vercel can now use lifespan events to run logic on startup and graceful shutdown, such as managing database connections or flushing external logs.
Lifespan events are defined with FastAPI's asynccontextmanager, running setup code before the yield and teardown code after it. Per the FastAPI on Vercel documentation, shutdown cleanup is limited to 500ms after Vercel sends the SIGTERM signal, and logs printed during that shutdown step won't appear in the Vercel dashboard.
Vercel
The platform for frontend developers — deploy, preview, and scale web apps and AI agents with zero config.
View Vercel →