fix(kyc): back off verification-progress poll instead of a fixed 5s interval#2336
Conversation
…nterval The verification-progress modal polled initiateSumsubKyc — a mutating endpoint — every 5s for the whole modal-open as a websocket fallback. For approved-LATAM users in the self-recovery state each call re-runs a full provider submission (86 in 20 min for one user, 2026-07-02); even with the BE cooldown each poll still costs ~3 provider calls + DB writes. Replace the fixed setInterval with a self-rescheduling setTimeout chain on a time-escalating schedule (5s for the first minute, then 10s → 20s → 60s) and stop polling after a ~15 min cap. The backoff is time-based, not error-based: the poll returns HTTP 200 even when the backend reprocess fails, so an error count would never escalate. The websocket stays the primary signal and the modal keeps its existing long-running state after the cap; re-opening restarts polling fresh.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 46 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Comment |
Code-analysis diffPainscore total: 5858.65 → 5858.95 (+0.3) 🆕 New findings (9)
✅ Resolved (8)
|
🧪 UI test report — ✅ all greenSuites
📊 Coverage (unit)
⏱ 10 slowest test cases
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
Incident (2026-07-02): while the KYC verification-progress modal is open,
useSumsubKycFlowfiredinitiateSumsubKycon a fixedsetInterval(..., 5000)as a websocket fallback — for the entire modal-open. That endpoint is mutating: for approved-LATAM users in the self-recovery state each call re-runs a full provider submission (86 re-submissions in 20 min for one user). Even with the new BE cooldown (api #1106), each poll still costs ~3 Sumsub API calls + DB writes on the create-action fall-through.Why time-based, not error-based: the poll requests succeed (HTTP 200) even when the backend reprocess fails, so an error-count backoff would never escalate. Backoff must be purely time-driven.
The change (hook-only): replace the fixed 5s
setIntervalwith a self-reschedulingsetTimeoutchain on a time-escalating schedule, plus an overall cap:After the ~15 min cap the modal stays in its existing long-running "Almost there" state (with its "Go to Home" CTA) and the websocket remains the only signal. Re-opening the modal restarts polling fresh. Cleanup on modal close / unmount cancels the pending timer (mirrors the old
clearIntervalsemantics; adds an in-flight guard so a poll resolving after teardown can't re-arm).Untouched by design: the websocket path,
handleInitiateKyc, and the initialfetchCurrentStatuseffect. Zero behavior change for flows that transition within the first minute (the common case).Risks / blast radius
QA
src/hooks/__tests__/useSumsubKycFlow.test.ts— cadence escalates 5s→10s→20s on schedule, polling stops at the cap, timer cleanup on modal close, timer cleanup on unmount, poll still callsinitiateSumsubKycwith the same{ regionIntent, levelName, targetCountry }args. Full suite: 106 suites / 1645 passing.