Skip to content

fix(kyc): actually apply the callback-ref fix (#2440 shipped the test only)#2441

Merged
Hugo0 merged 1 commit into
mainfrom
hotfix/sumsub-reapply-callback-ref
Jul 17, 2026
Merged

fix(kyc): actually apply the callback-ref fix (#2440 shipped the test only)#2441
Hugo0 merged 1 commit into
mainfrom
hotfix/sumsub-reapply-callback-ref

Conversation

@Hugo0

@Hugo0 Hugo0 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

⚠️ #2440 shipped the test but NOT the fix — this lands the actual fix

The card outage is still live. #2440 was supposed to fix it, but it merged the regression test without the code change.

How: while proving the test failed against prod code, I ran git checkout origin/main -- SumsubKycWrapper.tsx. That staged the reverted file. I restored the working tree with cp but never re-staged, so the follow-up commit swept the staged revert in. main ended up with a test asserting behaviour main doesn't have → its unit job is red, and every user still gets the spinner.

The fix (unchanged from what #2440 intended)

Hold the SDK container in state via a callback ref so the init effect re-runs when the headlessui portal attaches the node — which happens a commit after visible flips true.

Without it: the effect reads a null ref on its only run and never re-runs (a ref isn't reactive and isn't in the dep array) → sdk.launch() is never called → infinite spinner for 100% of users.

Deterministic, not a race — every useSumsubKycFlow call site does:

setAccessToken(response.data.token)
setShowWrapper(true)          // React 18 auto-batches → one commit

so accessToken + visible land together while sdkLoaded is already true (the wrapper is persistently mounted). All deps ready, container null, effect bails, done.

Matches prod exactly: card_sumsub_opened normal (137/day) vs card_sumsub_completed 0 (was 49–85/day), kyc_approved 0, cards 0 for 16h+.

Not Sumsub

Ruled out by direct API probe — the rain-requirements level is healthy:

docSets: [IDENTITY, SELFIE, APPLICANT_DATA, PHONE_VERIFICATION, EMAIL_VERIFICATION, QUESTIONNAIRE]
69c5b040…  questionnaire: [rain-card-extraInformation]  reviewStatus: completed/GREEN

Nothing renamed or deleted. Applicants with empty questionnaires are at reviewStatus: init — they never submitted, because the SDK never launched. That's the symptom, not the cause. Do not edit the Sumsub dashboard.

Verification

  • The test already on main fails against main's wrapper (launch called 0 times) and passes with this commit. That asymmetry is the proof the code change is really here.
  • eslint clean on the file, typecheck clean, prettier clean.
  • This also turns main's currently-red unit job green.

Risk

One file, 18 lines, Sumsub modal only. No API/contract change, no migration. Targets mainback-merge debt (main→dev).

Summary by CodeRabbit

  • Bug Fixes
    • Improved identity verification startup reliability when the verification window becomes visible.
    • Ensured the verification experience initializes only after its display area is ready, reducing loading issues and improving iframe rendering.

… only)

#2440 was meant to fix the card outage but landed the regression test WITHOUT
the code change: while proving the test failed against prod, a
`git checkout origin/main -- SumsubKycWrapper.tsx` staged the reverted file,
and the follow-up commit swept that staged revert in. Net effect: main got a
test asserting behaviour that main does not have. Its unit job is red and the
outage is still live.

Re-applies the fix on top of main, unchanged from what #2440 intended: hold the
SDK container in state via a callback ref so the init effect re-runs when the
headlessui portal attaches the node a commit after `visible` flips. Without it
the effect reads a null ref on its only run, never re-runs (a ref is not
reactive and is not a dep), and the SDK is never launched — every user gets an
infinite spinner (card_sumsub_opened normal, card_sumsub_completed 0).

Verified the honest way this time: the test ALREADY on main fails against
main's wrapper (launch called 0 times) and passes with this commit.
@cursor

cursor Bot commented Jul 17, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
peanut-wallet Building Building Preview, Comment Jul 17, 2026 12:55pm

Request Review

@Hugo0
Hugo0 merged commit 1c2eac8 into main Jul 17, 2026
15 of 19 checks passed
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 95762116-7716-4007-8eba-016a29f98e3a

📥 Commits

Reviewing files that changed from the base of the PR and between e22e51e and 2381d0d.

📒 Files selected for processing (1)
  • src/components/Kyc/SumsubKycWrapper.tsx

📝 Walkthrough

Walkthrough

SumsubKycWrapper now stores the SDK mount node in state through a callback ref, delaying initialization until the portal-rendered container attaches. SDK launch, iframe observation, lookup, and effect dependencies use the stateful container.

Changes

Sumsub SDK container lifecycle

Layer / File(s) Summary
Callback-ref container integration
src/components/Kyc/SumsubKycWrapper.tsx
The wrapper stores the mounted container in state and uses it for SDK initialization, launch, iframe observation, existing-iframe lookup, effect dependencies, and mount ref wiring.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: jjramirezn

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/sumsub-reapply-callback-ref

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed: dependency version conflict. Check your lock file or package.json.


Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Code-analysis diff

Painscore total: 6207.05 → 6207.05 (0)
Findings: 0 net (+0 new, -0 resolved)

@github-actions

Copy link
Copy Markdown
Contributor

🧪 UI test report — ✅ all green

Suites

  • unit: 1995 ran, 0 failed, 0 skipped, 34.8s

📊 Coverage (unit)

metric %
statements 59.5%
branches 43.3%
functions 48.4%
lines 59.8%
⏱ 10 slowest test cases
time test
4.5s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › never places two stickers in heavy overlap (broad seed sweep)
1.2s src/utils/__tests__/demo-api.test.ts › isDemoMode() is false when not running under Capacitor
0.5s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › every sticker stays within canvas at any count
0.4s src/app/actions/__tests__/api-headers-extended.test.ts › should not include apiKey in validateInviteCode body
0.4s src/app/actions/__tests__/api-headers.test.ts › should include Content-Type in validateInviteCode
0.3s src/app/(mobile-ui)/withdraw/__tests__/withdraw-states.test.tsx › Bank withdrawal keeps the $1 minimum for sub-$1 amounts
0.2s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › keeps stickers off the username pill (final pass respects the keep-out)
0.2s src/utils/__tests__/demo-balance.test.ts › auto-refills a stored balance that has no timestamp (legacy install)
0.2s src/utils/__tests__/demo-balance.test.ts › starts at the full balance on a fresh install and stamps a timestamp
0.2s src/utils/__tests__/demo-balance.test.ts › auto-refills a wallet older than the TTL on cold start
📍 Inline annotations are in the **Unit test report** check above. Coverage artifact: `coverage-unit`. Generated by `.github/workflows/tests.yml`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant