fix(sio-client): do not send a packet on an expired connection (#5134)
When a laptop is suspended or a phone is locked, the timer that is used to check the liveness of the connection is paused and is not able to detect that the heartbeat has failed. Previously, emitting a message after resuming the page would lose the message. The status of the timer will now be checked before sending the message, so that it gets buffered and sent upon reconnection. Note: we could also have used the Page Visibility API or a custom setTimeout() method based on setInterval(), but this would not be as reliable as the current solution. Reference: https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API Related: https://github.com/socketio/socket.io/issues/5135
T
Tom Jenkinson committed
8adcfbfde50679095ec2abe376650cf2b6814325
Parent: 7a23dde
Committed by Damien Arrachequesne <damien.arrachequesne@gmail.com>
on 9/18/2024, 9:11:22 AM