fix: handle lifespan errors gracefully
- Add error tracking in lifespan context manager - Only cleanup services that were successfully initialized - Properly handle startup errors without breaking async context - Fixes RuntimeError: generator didn't stop after athrow()
This commit is contained in:
@@ -118,59 +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
|
||||
- Details: BackgroundLoaderService.\_load_nfo_and_images() correctly passes serie_folder to create_tvshow_nfo(), which only processes that specific series
|
||||
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
|
||||
5. ✅ **Fix WebSocket Room Subscription Format** (Completed: 2026-01-23)
|
||||
- Task: Fix "Invalid room name: ." error
|
||||
- Issue: WebSocket message format was incorrect - sending {action: 'join', room: 'system'} instead of {action: 'join', data: {room: 'system'}}
|
||||
- Changes: Updated loading.html to send correct message format with nested data object
|
||||
6. ✅ **Fix Async Generator Exception Handling** (Completed: 2026-01-23)
|
||||
- Task: Fix "RuntimeError: generator didn't stop after athrow()" error during anime add
|
||||
- Issue: get_optional_database_session() async generator wasn't properly handling exceptions
|
||||
- Changes:
|
||||
- Simplified exception handling in both get_database_session() and get_optional_database_session()
|
||||
- Removed nested try-except inside yield that was causing generator issues
|
||||
- Let async context manager handle exceptions naturally
|
||||
7. ✅ **Initialization Restart Protection** (Completed: 2026-01-23)
|
||||
- Task: Ensure initialization doesn't restart on server restart by using database flags
|
||||
- Status: VERIFIED - Already implemented correctly
|
||||
- Details:
|
||||
- SystemSettings.initial_scan_completed flag already prevents re-running initialization
|
||||
- initialization_service checks this flag before performing series sync
|
||||
- All initialization steps (scan, NFO, media) have individual completion flags
|
||||
- Server restart properly skips already-completed steps
|
||||
|
||||
### Active Tasks:
|
||||
|
||||
(No active tasks - awaiting new requirements)
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user