Skip to content

fix: add max attempts timeout to scan polling loop#49

Merged
SatyamPandey-07 merged 2 commits into
harshika53:mainfrom
OmanshiRaj:fix/scanner-polling-timeout
Jul 5, 2026
Merged

fix: add max attempts timeout to scan polling loop#49
SatyamPandey-07 merged 2 commits into
harshika53:mainfrom
OmanshiRaj:fix/scanner-polling-timeout

Conversation

@OmanshiRaj

Copy link
Copy Markdown
Contributor

fixes #47
Fixes the unbounded polling loop in useScanner.ts where scan() would call getReport every 3 seconds indefinitely if the backend never transitioned status away from in_progress (e.g. crash, hang, or stalled worker). Added a maxAttempts guard (100 attempts ≈ 5 minutes at the existing 3s interval) inside the while loop; once exceeded, it throws 'Scan timed out. Please try again.', which is caught by the existing catch block and surfaced via setError, while the existing finally block resets isScanning to false — so the UI correctly exits the "Scanning..." state with no additional state wiring required. Also added status, scanId, and identifier to the ScanResult interface in src/types/index.ts so the repeated inline as ScanResult & {...} casts in the hook could be removed.


@SatyamPandey-07
SatyamPandey-07 merged commit 222ff8b into harshika53:main Jul 5, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] useScanner polls indefinitely with no timeout if scan status never leaves 'in_progress'

2 participants