-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[iOS][WebSocket] use correct delegate queue in RCTRSWebSocket #18530
Conversation
This commit makes the websocket's delegate dispatch queue use RCTWebSocketModule's method queue. This fixes a bug where didReceiveMessage was called on the wrong queue, which is especially harmful if the websocket has a contentHandler expects to be running on the RCTWebSocketModule's method queue.
Generated by 🚫 dangerJS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, just one small change
@@ -82,6 +82,7 @@ - (void)invalidate | |||
}]; | |||
|
|||
RCTSRWebSocket *webSocket = [[RCTSRWebSocket alloc] initWithURLRequest:request protocols:protocols]; | |||
[webSocket setDelegateDispatchQueue: _methodQueue]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove space, please follow implied style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ sorry bout that.
Android CI failed but it seems to be unrelated to this PR 🤔 |
@facebook-github-bot shipit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ide is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: This commit makes the websocket's delegate dispatch queue use `RCTWebSocketModule`'s method queue. This fixes a bug where didReceiveMessage was called on the wrong queue, which is especially harmful if the websocket has a contentHandler expects to be running on the RCTWebSocketModule's method queue. This also fixes the race condition where `_contentHandlers` and `_sockets` can be mutated from the main dispatch queue (the default in `RCTRSWebSocket`) and `RCTWebSocketModule`'s method queue. Websockets still work, and hopefully crash less now. - [iOS][BUGFIX][WebSocket] fix crashes caused by a race condition in websocket delegates. Closes facebook#18530 Differential Revision: D7394298 Pulled By: hramos fbshipit-source-id: 230466ccb47ea532ced15cd7603256a19077b32b
Summary: This commit makes the websocket's delegate dispatch queue use `RCTWebSocketModule`'s method queue. This fixes a bug where didReceiveMessage was called on the wrong queue, which is especially harmful if the websocket has a contentHandler expects to be running on the RCTWebSocketModule's method queue. This also fixes the race condition where `_contentHandlers` and `_sockets` can be mutated from the main dispatch queue (the default in `RCTRSWebSocket`) and `RCTWebSocketModule`'s method queue. Websockets still work, and hopefully crash less now. - [iOS][BUGFIX][WebSocket] fix crashes caused by a race condition in websocket delegates. Closes facebook#18530 Differential Revision: D7394298 Pulled By: hramos fbshipit-source-id: 230466ccb47ea532ced15cd7603256a19077b32b
Summary: This commit makes the websocket's delegate dispatch queue use `RCTWebSocketModule`'s method queue. This fixes a bug where didReceiveMessage was called on the wrong queue, which is especially harmful if the websocket has a contentHandler expects to be running on the RCTWebSocketModule's method queue. This also fixes the race condition where `_contentHandlers` and `_sockets` can be mutated from the main dispatch queue (the default in `RCTRSWebSocket`) and `RCTWebSocketModule`'s method queue. Websockets still work, and hopefully crash less now. - [iOS][BUGFIX][WebSocket] fix crashes caused by a race condition in websocket delegates. Closes facebook#18530 Differential Revision: D7394298 Pulled By: hramos fbshipit-source-id: 230466ccb47ea532ced15cd7603256a19077b32b
Summary: This commit makes the websocket's delegate dispatch queue use `RCTWebSocketModule`'s method queue. This fixes a bug where didReceiveMessage was called on the wrong queue, which is especially harmful if the websocket has a contentHandler expects to be running on the RCTWebSocketModule's method queue. This also fixes the race condition where `_contentHandlers` and `_sockets` can be mutated from the main dispatch queue (the default in `RCTRSWebSocket`) and `RCTWebSocketModule`'s method queue. Websockets still work, and hopefully crash less now. - [iOS][BUGFIX][WebSocket] fix crashes caused by a race condition in websocket delegates. Closes facebook#18530 Differential Revision: D7394298 Pulled By: hramos fbshipit-source-id: 230466ccb47ea532ced15cd7603256a19077b32b
Summary: This commit makes the websocket's delegate dispatch queue use `RCTWebSocketModule`'s method queue. This fixes a bug where didReceiveMessage was called on the wrong queue, which is especially harmful if the websocket has a contentHandler expects to be running on the RCTWebSocketModule's method queue. This also fixes the race condition where `_contentHandlers` and `_sockets` can be mutated from the main dispatch queue (the default in `RCTRSWebSocket`) and `RCTWebSocketModule`'s method queue. Websockets still work, and hopefully crash less now. - [iOS][BUGFIX][WebSocket] fix crashes caused by a race condition in websocket delegates. Closes facebook#18530 Differential Revision: D7394298 Pulled By: hramos fbshipit-source-id: 230466ccb47ea532ced15cd7603256a19077b32b
Summary: This commit makes the websocket's delegate dispatch queue use `RCTWebSocketModule`'s method queue. This fixes a bug where didReceiveMessage was called on the wrong queue, which is especially harmful if the websocket has a contentHandler expects to be running on the RCTWebSocketModule's method queue. This also fixes the race condition where `_contentHandlers` and `_sockets` can be mutated from the main dispatch queue (the default in `RCTRSWebSocket`) and `RCTWebSocketModule`'s method queue. Websockets still work, and hopefully crash less now. - [iOS][BUGFIX][WebSocket] fix crashes caused by a race condition in websocket delegates. Closes facebook#18530 Differential Revision: D7394298 Pulled By: hramos fbshipit-source-id: 230466ccb47ea532ced15cd7603256a19077b32b
Summary: This commit makes the websocket's delegate dispatch queue use `RCTWebSocketModule`'s method queue. This fixes a bug where didReceiveMessage was called on the wrong queue, which is especially harmful if the websocket has a contentHandler expects to be running on the RCTWebSocketModule's method queue. This also fixes the race condition where `_contentHandlers` and `_sockets` can be mutated from the main dispatch queue (the default in `RCTRSWebSocket`) and `RCTWebSocketModule`'s method queue. Websockets still work, and hopefully crash less now. - [iOS][BUGFIX][WebSocket] fix crashes caused by a race condition in websocket delegates. Closes facebook/react-native#18530 Differential Revision: D7394298 Pulled By: hramos fbshipit-source-id: 230466ccb47ea532ced15cd7603256a19077b32b
Motivation
This commit makes the websocket's delegate dispatch queue use
RCTWebSocketModule
's method queue.This fixes a bug where didReceiveMessage was called on the wrong queue, which is especially harmful if the websocket has a contentHandler expects to be running on the RCTWebSocketModule's method queue.
This also fixes the race condition where
_contentHandlers
and_sockets
can be mutated from the main dispatch queue (the default inRCTRSWebSocket
) andRCTWebSocketModule
's method queue.Test Plan
Websockets still work, and hopefully crash less now.
Release Notes