Permalink
Browse files

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
  • Loading branch information...
mmmulani authored and facebook-github-bot committed Dec 4, 2017
1 parent ad4450a commit 1e1e49124678f447d980bb22891d25db60fa83b3
Showing with 2 additions and 0 deletions.
  1. +2 −0 Libraries/WebSocket/RCTWebSocketModule.m
@@ -163,6 +163,7 @@ - (void)webSocket:(RCTSRWebSocket *)webSocket didFailWithError:(NSError *)error
{
NSNumber *socketID = [webSocket reactTag];
_contentHandlers[socketID] = nil;
_sockets[socketID] = nil;
[self sendEventWithName:@"websocketFailed" body:@{
@"message": error.localizedDescription,
@"id": socketID
@@ -176,6 +177,7 @@ - (void)webSocket:(RCTSRWebSocket *)webSocket
{
NSNumber *socketID = [webSocket reactTag];
_contentHandlers[socketID] = nil;
_sockets[socketID] = nil;
[self sendEventWithName:@"websocketClosed" body:@{
@"code": @(code),
@"reason": RCTNullIfNil(reason),

1 comment on commit 1e1e491

@kesha-antonov

This comment has been minimized.

kesha-antonov commented on 1e1e491 Dec 5, 2017

Thanks!

Please sign in to comment.