Skip to content

Commit 1e1e491

Browse files
Mehdi Mulanifacebook-github-bot
Mehdi Mulani
authored andcommitted
Avoid memory leak in RCTWebSocketModule
Summary: Though this module is dev-only, if not connected to the packager it will collect websockets forever. Some estimate it'll take up 200MB after like 20 minutes. Reviewed By: shergin Differential Revision: D6464304 fbshipit-source-id: bef1ce967e4c13dd29e3c7ab4228e9c88d02c157
1 parent ad4450a commit 1e1e491

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Libraries/WebSocket/RCTWebSocketModule.m

+2
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ - (void)webSocket:(RCTSRWebSocket *)webSocket didFailWithError:(NSError *)error
163163
{
164164
NSNumber *socketID = [webSocket reactTag];
165165
_contentHandlers[socketID] = nil;
166+
_sockets[socketID] = nil;
166167
[self sendEventWithName:@"websocketFailed" body:@{
167168
@"message": error.localizedDescription,
168169
@"id": socketID
@@ -176,6 +177,7 @@ - (void)webSocket:(RCTSRWebSocket *)webSocket
176177
{
177178
NSNumber *socketID = [webSocket reactTag];
178179
_contentHandlers[socketID] = nil;
180+
_sockets[socketID] = nil;
179181
[self sendEventWithName:@"websocketClosed" body:@{
180182
@"code": @(code),
181183
@"reason": RCTNullIfNil(reason),

0 commit comments

Comments
 (0)