PeelTechnologies / react-native-tcp

node's net api in react-native
MIT License
284 stars 213 forks source link

TcpSocketClient callback queues are being lost between instances #86

Open beau6183 opened 6 years ago

beau6183 commented 6 years ago

I can submit a sample project to prove the issue, but it appears that callbacks are being referenced from different instances of TcpSocketClient and failing.

TcpSockets creates an instance of TcpSocketClient at init. Then, on first client connection, a new TcpSocketClient instance is created by TcpSockets, but the callbacks from write are saved in the first instances's _pendingSends. When the message is written to the socket and the callback is requested to call, the second instance checks it's own _pendingSends for the callback and cannot locate it. This causes a lock on writes after the first message is sent.

I have a fix which moves the _pendingWrites queue (and _sendTag) to the delegate and handled centrally through delegate handlers. Will submit a PR.