mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 09:45:04 +00:00
(upstream) Prevent SocketRocket killing the connection before notifying of final messages
Summary: wrap NSStreamEventEndEncountered in dispatch_async _workQueue per upstream: https://github.com/square/SocketRocket/pull/294 CLA completed Closes https://github.com/facebook/react-native/pull/3493 Reviewed By: svcscm Differential Revision: D2554892 Pulled By: javache fb-gh-sync-id: 347a37eb95b20b7e92b985b6908e15462672e83c
This commit is contained in:
parent
9dc036d2b9
commit
607527c0d4
@ -1381,20 +1381,22 @@ static const size_t RCTSRFrameHeaderOverhead = 32;
|
||||
if (aStream.streamError) {
|
||||
[self _failWithError:aStream.streamError];
|
||||
} else {
|
||||
if (self.readyState != RCTSR_CLOSED) {
|
||||
self.readyState = RCTSR_CLOSED;
|
||||
_selfRetain = nil;
|
||||
}
|
||||
dispatch_async(_workQueue, ^{
|
||||
if (self.readyState != RCTSR_CLOSED) {
|
||||
self.readyState = RCTSR_CLOSED;
|
||||
_selfRetain = nil;
|
||||
}
|
||||
|
||||
if (!_sentClose && !_failed) {
|
||||
_sentClose = YES;
|
||||
// If we get closed in this state it's probably not clean because we should be sending this when we send messages
|
||||
[self _performDelegateBlock:^{
|
||||
if ([self.delegate respondsToSelector:@selector(webSocket:didCloseWithCode:reason:wasClean:)]) {
|
||||
[self.delegate webSocket:self didCloseWithCode:RCTSRStatusCodeGoingAway reason:@"Stream end encountered" wasClean:NO];
|
||||
}
|
||||
}];
|
||||
}
|
||||
if (!_sentClose && !_failed) {
|
||||
_sentClose = YES;
|
||||
// If we get closed in this state it's probably not clean because we should be sending this when we send messages
|
||||
[self _performDelegateBlock:^{
|
||||
if ([self.delegate respondsToSelector:@selector(webSocket:didCloseWithCode:reason:wasClean:)]) {
|
||||
[self.delegate webSocket:self didCloseWithCode:RCTSRStatusCodeGoingAway reason:@"Stream end encountered" wasClean:NO];
|
||||
}
|
||||
}];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user