Fix async generator exception handling in get_optional_database_session
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -118,35 +118,3 @@ For each task completed:
|
||||
---
|
||||
|
||||
## TODO List:
|
||||
|
||||
### Completed Tasks:
|
||||
|
||||
1. ✅ **NFO/Artwork Loading Isolation** (Completed: 2026-01-23)
|
||||
- Task: Ensure during anime add, NFO, logo, art, etc. is loaded only for the specific anime being added
|
||||
- Status: VERIFIED - Implementation is correct
|
||||
2. ✅ **Setup Redirect Flow** (Completed: 2026-01-23)
|
||||
- Task: Implement redirect flow: setup -> loading -> login when user completes setup
|
||||
- Changes:
|
||||
- Added /loading to exempt paths in setup_redirect middleware
|
||||
- Setup page redirects to loading with initialization in background
|
||||
- Loading page connects to WebSocket for real-time progress
|
||||
- After completion, loading redirects to login
|
||||
3. ✅ **Close Setup and Loading Pages** (Completed: 2026-01-23)
|
||||
- Task: Make setup and loading pages unavailable after completion to prevent re-access
|
||||
- Changes:
|
||||
- Check if setup is complete before allowing access to /setup
|
||||
- Redirect to login if accessing /setup after completion
|
||||
- Check if initialization is complete before allowing access to /loading
|
||||
- Redirect to login if accessing /loading after initialization complete
|
||||
4. ✅ **Fix Loading Page WebSocket Auth** (Completed: 2026-01-23)
|
||||
- Task: Fix 403 Forbidden error on WebSocket connection
|
||||
- Issue: Loading page was connecting to /ws/progress (doesn't exist)
|
||||
- Changes:
|
||||
- Changed WebSocket URL from /ws/progress to /ws/connect (correct endpoint)
|
||||
- Added /ws/connect to exempt paths in auth middleware
|
||||
- Subscribe to 'system' room after connection for progress updates
|
||||
- Fixed message data handling to match WebSocket format
|
||||
|
||||
### Active Tasks:
|
||||
|
||||
(No active tasks - awaiting new requirements)
|
||||
|
||||
@@ -170,7 +170,12 @@ async def get_optional_database_session() -> AsyncGenerator:
|
||||
from src.server.database import get_db_session
|
||||
|
||||
async with get_db_session() as session:
|
||||
yield session
|
||||
try:
|
||||
yield session
|
||||
except Exception:
|
||||
# Re-raise to let FastAPI handle it properly
|
||||
# This prevents "generator didn't stop after athrow()" error
|
||||
raise
|
||||
except (ImportError, RuntimeError):
|
||||
# Database not available - yield None
|
||||
yield None
|
||||
|
||||
Reference in New Issue
Block a user