Skip to content

Commit

Permalink
FIX: [Storage] Don't try resolving the promise twice if an error occu…
Browse files Browse the repository at this point in the history
  • Loading branch information
TPXP authored and greenbull-tpathier committed Dec 18, 2020
1 parent fa28299 commit b1ae0dc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/storage/ios/RNFBStorage/RNFBStorageModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,16 @@ - (void)invalidate {
) {
FIRStorageReference *storageReference = [self getReferenceFromUrl:url app:firebaseApp];

__block bool alreadyCompleted = false;

id completionBlock = ^(FIRStorageListResult *result, NSError *error) {
// This may be called multiple times if an error occurs
// Make sure we won't try to resolve the promise twice in this case
// See https://github.com/firebase/firebase-ios-sdk/blob/14764b8d60a6ad023d8fa5b7f81d42378d92e6fe/FirebaseStorage/Sources/FIRStorageReference.m#L417
if(alreadyCompleted) {
return;
}
alreadyCompleted = true;
if (error != nil) {
[self promiseRejectStorageException:reject error:error];
} else {
Expand Down

0 comments on commit b1ae0dc

Please sign in to comment.