From 02a36a97d979d52f42554c896dcce7bc986adb1b Mon Sep 17 00:00:00 2001 From: Vacbo Date: Sat, 30 May 2026 19:14:13 -0300 Subject: [PATCH] fix: use try/finally in get_db to prevent PostgreSQL connection leaks --- backend/app/api/deps.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/app/api/deps.py b/backend/app/api/deps.py index c2b83c841d..5070eabcb9 100644 --- a/backend/app/api/deps.py +++ b/backend/app/api/deps.py @@ -19,8 +19,11 @@ def get_db() -> Generator[Session, None, None]: - with Session(engine) as session: + session = Session(engine) + try: yield session + finally: + session.close() SessionDep = Annotated[Session, Depends(get_db)]