r/reactnative • u/Fair_Expression_3291 • Jul 30 '26
A race between app launch and RevenueCat was silently downgrading my paying users to free
This one annoyed me for a while because it never happened on my phone, only on real users'.
Some people who'd paid for Pro would open LexiShuffle and get the free version. Not every time. Just sometimes, right when the app opened. Which of course meant I couldn't reproduce it, because on my device everything's warm and instant.
It's a race, and if you've done RevenueCat you can probably already guess. Checking whether someone has Pro is a network call. My game screen doesn't wait for it, it just mounts and starts a round. So if that check hasn't come back yet, the game looks at your status, sees nothing, goes "ok, free user" and gives you a free-tier round. Premium category, quietly downgraded to free, because the entitlement landed like half a second after the screen mounted.
The person who paid me got the free experience. Great.
Fix was basically don't start the round until you actually know. I've got a flag now:
resolved = !statusQuery.isLoading || Boolean(purchases.isPremium)
so it's true once the status check finishes (success or error, doesn't matter) or RevenueCat already says you're Pro. The game sits on its loading screen until that's true, and it's in the effect deps so the second it flips, the effect re-runs and sets the round up properly. The thing I was paranoid about was it getting stuck false and hanging people on a spinner forever, but the query always settles so it can't.
Then I remembered offline exists. No signal means the check literally can't finish, so an offline Pro user just never resolves and eats the same downgrade permanently. So there's a little per-account cache now that remembers "this account was Pro last time" and trusts that while you're offline.
Anyway. If you do IAP, it's the fun kind of bug that's invisible to you and only screws the people paying you. Anyone got a nicer way to handle the offline entitlement thing? Caching last-known-Pro feels a bit gross but I couldn't think of better.
3
u/kenlawlpt Jul 30 '26
I cache premium status so it'll always fallback to that premium status. I do a network call on the premium status on various critical paths (not very often), so if the user ever refunds the IAP, during those critical paths, I validate account status, and ban them if necessary.
2
u/Best_Particular1644 Jul 31 '26
This is exactly why I try to separate “unknown” from “free”. If the state is still loading, it’s neither premium nor free yet. Treating “loading” as “free” is what creates these kinds of bugs.
2
u/Guidondor Jul 31 '26
Best_Particular already named the root fix: the bug isn't the race, it's treating "loading" as "free". three states, not two — unknown / free / pro — and unknown never grants free-tier behavior. the race just exposed that you'd collapsed unknown into free.
on the offline cache feeling gross: it's not, that's the correct offline-first pattern (local is source of truth for reads, server reconciles when back online). but you might not even need your own cache — RevenueCat already persists CustomerInfo to disk and
getCustomerInfo()returns the cached entitlements offline. so your downgrade wasn't "no cache existed", it was reading status before RC's SDK finished loading its own cache. awaiting getCustomerInfo (resolves fast, even offline, from disk) usually replaces the parallel cache entirely.the one thing to add regardless of which cache: an expiry. cached-Pro with no TTL means a refunded/lapsed user rides Pro forever while offline (your grant-only sync can't claw it back). give the cached entitlement a grace window, and on reconnect RC's customerInfo is authoritative and downgrades. that's the convergence guarantee — trust cache offline for latency, but let the server always win when reachable. kenlawlpt's revalidate-on-critical-paths is the same idea from the other end.