Skip to content

Make close() method also clear the shared instance of the SDK#2940

Merged
tonidero merged 5 commits into
mainfrom
make-close-method-also-clear-shared-instance
Dec 17, 2025
Merged

Make close() method also clear the shared instance of the SDK#2940
tonidero merged 5 commits into
mainfrom
make-close-method-also-clear-shared-instance

Conversation

@tonidero

Copy link
Copy Markdown
Contributor

Description

When calling the close function, we cleared a bunch of internal state that leaves the SDK in an inconsistent state. Specifically, we clear the billing client from the BillingWrapper, among other things. If after that, you tried to reconfigure the SDK with the exact same configuration, it wouldn't let you, since we have logic to prevent reconfigurations with the same config. This means that in some cases, we would end up in this inconsistent state, without a great way to get out of it.

I think the close function means the instance shouldn't be called more, so we should also clear the shared instance, so we can actually reinitialize later if needed and Purchases.isConfigured is false. This is however a behavior change.

@tonidero tonidero added the pr:fix A bug fix label Dec 16, 2025
@tonidero tonidero marked this pull request as ready for review December 16, 2025 11:07
@tonidero tonidero requested a review from a team as a code owner December 16, 2025 11:07
@tonidero tonidero requested a review from vegaro December 16, 2025 11:08
@codecov

codecov Bot commented Dec 16, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.82%. Comparing base (7c285c9) to head (9176049).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2940   +/-   ##
=======================================
  Coverage   78.82%   78.82%           
=======================================
  Files         337      337           
  Lines       13129    13129           
  Branches     1771     1771           
=======================================
  Hits        10349    10349           
  Misses       2038     2038           
  Partials      742      742           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vegaro vegaro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the behavior change is fine because it wouldn't work anyways right?

@tonidero

Copy link
Copy Markdown
Contributor Author

I think the behavior change is fine because it wouldn't work anyways right?

Indeed, I think it should be fine... I guess before this, you could continue doing some operations with the SDK if you had some cached values, but it's indeed in an inconsistent state, so I think normally the changes of this PR include how it should behave

@ajpallares ajpallares left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!

@tonidero tonidero added this pull request to the merge queue Dec 17, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 17, 2025
@tonidero tonidero enabled auto-merge December 17, 2025 11:49
@emerge-tools

emerge-tools Bot commented Dec 17, 2025

Copy link
Copy Markdown

📸 Snapshot Test

569 unchanged

Name Added Removed Modified Renamed Unchanged Errored Approval
TestPurchasesUIAndroidCompatibility
com.revenuecat.testpurchasesuiandroidcompatibility
0 0 0 0 312 0 N/A
TestPurchasesUIAndroidCompatibility Paparazzi
com.revenuecat.testpurchasesuiandroidcompatibility.paparazzi
0 0 0 0 257 0 N/A

🛸 Powered by Emerge Tools

@tonidero tonidero added this pull request to the merge queue Dec 17, 2025
Merged via the queue into main with commit 842f77b Dec 17, 2025
23 checks passed
@tonidero tonidero deleted the make-close-method-also-clear-shared-instance branch December 17, 2025 15:21
This was referenced Dec 17, 2025
tonidero added a commit that referenced this pull request Dec 18, 2025
## RevenueCat SDK
### ✨ New Features
* Adds `setAppsFlyerConversionData` to conveniently track AppsFlyer
conversion data (#2931) via JayShortway (@JayShortway)
### 🐞 Bugfixes
* Make close() method also clear the shared instance of the SDK (#2940)
via Toni Rico (@tonidero)
* Fix purchase callback not firing for DEFERRED product changes with
baePlanId in oldProductId (#2937) via Facundo Menzella (@facumenzella)

### 🔄 Other Changes
* [AUTOMATIC] Update golden test files for backend integration tests
(#2949) via RevenueCat Git Bot (@RCGitBot)
* [AUTOMATIC] Update golden test files for backend integration tests
(#2944) via RevenueCat Git Bot (@RCGitBot)
* Adds `.kotlin` to `.gitignore` (#2941) via JayShortway (@JayShortway)
* Dont use reflection to instantiate AmazonOfferingParser (#2934) via
Will Taylor (@fire-at-will)

---------

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Co-authored-by: Toni Rico <toni.rico.diez@revenuecat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants