mirror of
https://github.com/livekit/livekit.git
synced 2026-09-02 13:35:25 +00:00
* Flush pending signal responses before closing the web socket. When the request direction of a signalling connection goes away, the web socket was closed right away. Responses that the participant had already sent were dropped. This loses the leave request on migration. The media node writes leave(RESUME) and closes the signalling connection just after. The close won the race, so the client saw a plain web socket close with code 1000 and never got the leave. It then did a full reconnect instead of a resume. Now the response pump is signalled first and drains what is pending, then the web socket is closed. The producer closes the response source after its last write, so draining till the source is closed is a complete flush. A deadline bounds the case where the source stays open. The web socket is still closed on all paths, so the ping worker does not leak. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * Give the response pump a margin over the drain deadline. Both waits used the same timeout and started at about the same time. So when the drain ran to its deadline, the outer wait could give up at the same moment and close the web socket while the pump was still writing. That write failed and the message was lost. It also logged a timeout even though nothing was stuck. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>