fix: mark stale running scans as failed on restart; stop unconditional polling - #107
Merged
Merged
Conversation
…l polling Backend (main.py): - _mark_interrupted_scans() runs in lifespan after init_db() - Finds all scans with status='running', sets status='failed', error_message='Scan interrupted by server restart', current_stage=None - Wrapped in try/except so a pre-migration DB never crashes startup Frontend (useScanStatus.ts): - Replaces unconditional 3s polling with adaptive intervals: - 3s fast-poll only while a scan is running - 30s slow-poll when idle (was: always 3s, even at rest) - Interval is rescheduled whenever running state changes Fixes: stale '102m 0s running scan' after restart + dozens of /api/scans requests per minute when nothing is happening Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Owner
Author
|
Implemented in #107. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After a container restart, any scan that was
status='running'when the container was killed remains stuck in that state forever. The frontend then polls/api/scansevery 3 seconds indefinitely, generating 50+ requests/minute even when nothing is happening.Fix
Backend —
app/main.py_mark_interrupted_scans(): called in lifespan startup afterinit_db()status='running', sets them tostatus='failed'witherror_message='Scan interrupted by server restart'try/exceptso a pre-migration local DB never prevents the server from startingFrontend —
hooks/useScanStatus.tsTesting
Closes #107