fix(eio,eio-client): do not close the connection while packets are still being received#5524
Open
GiHoon1123 wants to merge 1 commit into
Open
Conversation
…ill being received The server (and, symmetrically, the client) would close the connection on a ping timeout even while other packets kept arriving, because only the pong (or a fresh ping, on the client) reset the timeout - a high-throughput connection could be dropped despite clear evidence it was still alive. A previous fix for this (be7b4e7) was reverted (5359bae) for allocating a new timer per packet and for delaying the next scheduled ping as a side effect. This tracks a plain timestamp of the last received packet instead of touching any timer on the common path, and only affects whether an already-scheduled timeout check closes the connection or is extended - the ping/pong schedule itself is untouched. Both sides needed the fix: delaying the server's wait for a pong also delays its next ping, so without a matching client-side check the client's own, independent ping-timeout watchdog would still close the connection on its own once the delay exceeded pingTimeout. Also updates `_hasPingExpired()`, the synchronous check used by the Socket.IO client layer to detect a throttled/delayed timeout timer, to apply the same recent-packet check before deciding the connection is stale. Fixes socketio#5450
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5450.
The connection could be closed on a ping timeout even while other packets kept arriving, because only the pong (server side) or a fresh ping (client side) reset the timeout - a high-throughput connection could be dropped despite clear evidence it was still alive.
A previous fix for this (be7b4e7) was reverted (5359bae) for two reasons: it allocated a new timer on every incoming packet, and it delayed the next scheduled ping as a side effect (since only the timeout timer was touched, not the interval timer).
This takes a different approach:
pingIntervalTimeron the server, the client's own ping-driven timer) is never touched, so there's no change to when pings are sent.Both
engine.ioandengine.io-clientneeded the change. Delaying the server's wait for a pong also delays the server's next ping; without a matching client-side check, the client's own independent ping-timeout watchdog would still close the connection on its own once that delay exceededpingTimeout. This was confirmed by testing the server-only fix in isolation - the client still disconnected on its own._hasPingExpired(), the synchronous check the Socket.IO client layer uses to detect a throttled/delayed timeout timer, is also updated to apply the same recent-packet check before deciding the connection is stale, since it's a separate path that can bypass the timer-based check entirely.Test plan
_hasPingExpired()returnsfalsewhen a packet was recently received, even if the throttled-timer deadline has passedengine.iosuite passes for both protocol v4 and legacy v3 (EIO_CLIENT=3)engine.io-clientsuite passesgit stashon just that file) and confirming the corresponding new test fails without it, then restoring and reconfirming it passes🤖 Generated with Claude Code