Skip to content

Commit 56fadd6

Browse files
Fixing tests
1 parent e0dbc12 commit 56fadd6

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Firestore/Source/Remote/FSTStream.m

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,17 +381,18 @@ - (void)closeWithFinalState:(FSTStreamState)finalState error:(nullable NSError *
381381
_messageReceived = NO;
382382
_rpc = nil;
383383

384-
// Clear the delegates to avoid any possible bleed through of events from GRPC.
385384
FSTAssert(_delegate,
386385
@"closeWithFinalState should only be called for a started stream that has an active "
387386
@"delegate.");
388-
_delegate = nil;
389387

390388
// If the caller explicitly requested a stream stop, don't notify them of a closing stream (it
391389
// could trigger undesirable recovery logic, etc.).
392390
if (finalState != FSTStreamStateStopped) {
393391
[self notifyStreamInterruptedWithError:error];
394392
}
393+
394+
// Clear the delegates to avoid any possible bleed through of events from GRPC.
395+
_delegate = nil;
395396
}
396397

397398
- (void)stop {
@@ -615,7 +616,9 @@ - (void)notifyStreamOpen {
615616
}
616617

617618
- (void)notifyStreamInterruptedWithError:(nullable NSError *)error {
618-
[self.delegate watchStreamWasInterruptedWithError:error];
619+
id<FSTWatchStreamDelegate> delegate = self.delegate;
620+
self.delegate = nil;
621+
[delegate watchStreamWasInterruptedWithError:error];
619622
}
620623

621624
- (void)watchQuery:(FSTQueryData *)query {
@@ -701,7 +704,9 @@ - (void)notifyStreamOpen {
701704
}
702705

703706
- (void)notifyStreamInterruptedWithError:(nullable NSError *)error {
704-
[self.delegate writeStreamWasInterruptedWithError:error];
707+
id<FSTWriteStreamDelegate> delegate = self.delegate;
708+
self.delegate = nil;
709+
[delegate writeStreamWasInterruptedWithError:error];
705710
}
706711

707712
- (void)tearDown {

0 commit comments

Comments
 (0)