@umituz/react-native-subscription 2.37.27 → 2.37.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-subscription",
|
|
3
|
-
"version": "2.37.
|
|
3
|
+
"version": "2.37.29",
|
|
4
4
|
"description": "Complete subscription management with RevenueCat, paywall UI, and credits system for React Native apps",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -40,16 +40,15 @@ export class InitializationCache {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
setPromise(promise: Promise<boolean>, userId: string): void {
|
|
43
|
-
// Add to pending queue immediately (atomic operation)
|
|
44
|
-
this.pendingQueue.set(userId, promise);
|
|
45
|
-
|
|
46
|
-
this.initPromise = promise;
|
|
47
43
|
this.promiseUserId = userId;
|
|
48
44
|
this.promiseCompleted = false;
|
|
49
45
|
|
|
50
46
|
const targetUserId = userId;
|
|
51
47
|
|
|
52
|
-
|
|
48
|
+
// Build the handled chain that ALWAYS resolves (never rejects).
|
|
49
|
+
// This is critical: pendingQueue must store a non-rejectable promise so that
|
|
50
|
+
// callers who receive it via tryAcquireInitialization never get an unhandled rejection.
|
|
51
|
+
const chain: Promise<boolean> = promise
|
|
53
52
|
.then((result) => {
|
|
54
53
|
if (result && this.promiseUserId === targetUserId) {
|
|
55
54
|
this.currentUserId = targetUserId;
|
|
@@ -65,12 +64,16 @@ export class InitializationCache {
|
|
|
65
64
|
}
|
|
66
65
|
this.promiseCompleted = true;
|
|
67
66
|
console.error('[InitializationCache] Initialization failed', { userId: targetUserId, error });
|
|
68
|
-
return false;
|
|
67
|
+
return false as boolean;
|
|
69
68
|
})
|
|
70
69
|
.finally(() => {
|
|
71
70
|
// Remove from queue when complete
|
|
72
71
|
this.pendingQueue.delete(targetUserId);
|
|
73
72
|
});
|
|
73
|
+
|
|
74
|
+
// Store the chain (not the original promise) so callers never receive a rejection
|
|
75
|
+
this.initPromise = chain;
|
|
76
|
+
this.pendingQueue.set(userId, chain);
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
getCurrentUserId(): string | null {
|