Skip to content

Commit

Permalink
Avoid memory leak in RCTWebSocketModule
Browse files Browse the repository at this point in the history
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
Mehdi Mulani authored and facebook-github-bot committed Dec 4, 2017
1 parent ad4450a commit 1e1e491
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Libraries/WebSocket/RCTWebSocketModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
Expand Down

1 comment on commit 1e1e491

@kesha-antonov
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Please sign in to comment.