refactor(kyc-controller): reconcile getSessionStatus/fetchKyCstatus, userStatus/sessionStatus, and polling - #10276
Conversation
| this.#ensurePolling(); | ||
| } else { | ||
| this.#stopUserStatusPolling(); | ||
| this.#stopPolling(); |
There was a problem hiding this comment.
Terminal refresh leaves sub-flow polling
High Severity
Combining the poll loops lets refreshKycStatus stop the post-SDK wait when it sees a terminal sessionStatus, but that path records status without #updateSumSubOnTerminal. After a failed first poll — or a later consumer/consents refresh — sumsub.status can stay polling even though verification already finished.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit adea851. Configure here.
There was a problem hiding this comment.
only matters if you consume sumsub.status state which mobile does not currently do. I do not want to remove sumsub.status at this time because it requires unraveling more logic and this PR is plenty big already
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c8e9d72. Configure here.
| } | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
Stale session reused after restart
High Severity
Persisting sessionId makes startSumSub treat a leftover id as the current UKYC session and skip #createUkycSession. After a restart, initialize starts a fresh flow but does not clear that id, so the MoonPay path reuses the prior session for createJourney. A spent or rejected session can then fail the retry or be mapped to already-completed via session_not_in_valid_state.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit c8e9d72. Configure here.
…-fetchKycStatus-polling


Explanation
Previously the kyc-controller had two separate
UserStatusandKycStatustypes which were basically the same. They also had two separate loops. This PR dropsUserStatusin favor ofKycStatuswhich is mostly referenced assessionStatusnow. Additionally,sessionIdis now persisted in state.userStatus,userStatusSumsubSessionId,userStatusErrorCodehave been removed from state in favor ofsessionStatusReferences
Checklist
Note
High Risk
Multiple breaking public API and state-shape changes affect Money toast and KYC consumers; status now depends on a persisted session id and throws when it is missing.
Overview
This PR replaces the user-keyed
GET /kyc/statuspath with the UKYC session status API.refreshKycStatus,KycController:statusChanged, and polling now useGET /sessions/{id}/statusviagetSessionStatus, andKycService.fetchKycStatusis removed.State and types are consolidated: active
sessionId(persisted) andsessionStatusmove to the root ofKycControllerState;userStatusand related fields are dropped. The simplified toast enum becomesKycSessionStatus; the full API payload isKycSessionStatusResponse.Polling is merged onto a single loop driven by
sessionStatusPollIntervalMs(replacinguserStatusPollIntervalMs), shared by post-SDK decision waits and pendingrefreshKycStatuspolls—with guards so terminal outcomes andreset()races are handled safely.Reviewed by Cursor Bugbot for commit ae12050. Bugbot is set up for automated code reviews on this repo. Configure here.