Skip to content

Commit

Permalink
fix(database): fix race condition for iOS
Browse files Browse the repository at this point in the history
The exception raised is 'createRepo called for Repo that already exists.'
in FRepoManager.m
It looks like we have to call the firebase database reference from the same
thread/queue otherwise we have a race condition leading to that exception.
  • Loading branch information
jeanregisser authored Mar 12, 2020
1 parent 7c704d1 commit 93497f5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ios/RNFirebase/database/RNFirebaseDatabase.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ - (id)init {
path:(NSString *)path
transactionId:(nonnull NSNumber *)transactionId
applyLocally:(BOOL)applyLocally) {
FIRDatabaseReference *ref = [self getReferenceForAppPath:appDisplayName dbURL:dbURL path:path];
dispatch_async(_transactionQueue, ^{
NSMutableDictionary *transactionState = [NSMutableDictionary new];
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
transactionState[@"semaphore"] = sema;
FIRDatabaseReference *ref = [self getReferenceForAppPath:appDisplayName dbURL:dbURL path:path];

[ref runTransactionBlock:^FIRTransactionResult *_Nonnull (FIRMutableData *_Nonnull currentData) {
dispatch_barrier_async(_transactionQueue, ^{
Expand Down

0 comments on commit 93497f5

Please sign in to comment.