@umituz/react-native-firebase 1.13.94 → 1.13.96

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-firebase",
3
- "version": "1.13.94",
3
+ "version": "1.13.96",
4
4
  "description": "Unified Firebase package for React Native apps - Auth and Firestore services using Firebase JS SDK (no native modules).",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -25,6 +25,8 @@ interface AuthActions {
25
25
  }
26
26
 
27
27
  let unsubscribe: (() => void) | null = null;
28
+ // Mutex flag to prevent race condition in setupListener
29
+ let setupInProgress = false;
28
30
 
29
31
  export const useFirebaseAuthStore = createStore<AuthState, AuthActions>({
30
32
  name: "firebase-auth-store",
@@ -39,10 +41,13 @@ export const useFirebaseAuthStore = createStore<AuthState, AuthActions>({
39
41
  setupListener: (auth: Auth) => {
40
42
  const state = get();
41
43
 
42
- if (state.listenerSetup || unsubscribe) {
44
+ // Atomic check: both state flag AND in-progress mutex
45
+ if (state.listenerSetup || unsubscribe || setupInProgress) {
43
46
  return;
44
47
  }
45
48
 
49
+ // Set mutex immediately (synchronous, before any async operation)
50
+ setupInProgress = true;
46
51
  set({ listenerSetup: true });
47
52
 
48
53
  unsubscribe = onAuthStateChanged(auth, (currentUser: User | null) => {
@@ -66,6 +71,8 @@ export const useFirebaseAuthStore = createStore<AuthState, AuthActions>({
66
71
  unsubscribe();
67
72
  unsubscribe = null;
68
73
  }
74
+ // Reset mutex on cleanup
75
+ setupInProgress = false;
69
76
  set({
70
77
  user: null,
71
78
  loading: true,
@@ -3,21 +3,12 @@
3
3
  * Creates a ready-to-use InitModule for app initialization
4
4
  */
5
5
 
6
+ import type { InitModule } from '@umituz/react-native-design-system';
6
7
  import { initializeAllFirebaseServices } from '../infrastructure/config/FirebaseClient';
7
8
  import { initializeFirebaseAuth } from '../auth/infrastructure/config/FirebaseAuthClient';
8
9
 
9
10
  declare const __DEV__: boolean;
10
11
 
11
- /**
12
- * InitModule interface (from @umituz/react-native-design-system)
13
- */
14
- export interface InitModule {
15
- name: string;
16
- init: () => Promise<boolean>;
17
- critical?: boolean;
18
- dependsOn?: string[];
19
- }
20
-
21
12
  export interface FirebaseInitModuleConfig {
22
13
  /**
23
14
  * Custom auth initializer function