Skip to content

fix(client): discard timed-out packets from the Engine.IO buffer - #5560

Open
dyk1454683243-sudo wants to merge 1 commit into
socketio:mainfrom
dyk1454683243-sudo:cursor/fix-timed-out-buffered-event-4eb2
Open

dyk1454683243-sudo wants to merge 1 commit into
socketio:mainfrom
dyk1454683243-sudo:cursor/fix-timed-out-buffered-event-4eb2

Conversation

@dyk1454683243-sudo

Copy link
Copy Markdown

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behavior

An event emitted with timeout() while the connection is still considered open can already be sitting in the Engine.IO write buffer (transport temporarily unwritable, for example after a network disruption that has not closed the socket yet).

When the acknowledgement times out, Socket.IO removes the packet from its own sendBuffer, but the encoded Engine.IO packet remains queued. Restoring the network / making the transport writable again flushes that timed-out event to the server.

This is #4318.

New behavior

On acknowledgement timeout the client also removes every Engine.IO packet created from that Socket.IO event, as long as none of them has been handed to the transport yet.

If any encoded packet is already part of the current flush batch, all related packets are left intact so a binary event cannot be partially transmitted.

Neighboring in-flight events are still flushed normally.

Other information (e.g. related issues)

Fixes #4318.

Regression coverage:

  • Engine.IO write-buffer removal, including the partially-flushed safety boundary
  • Socket.IO timeout: timed-out event is not delivered after the transport becomes writable again (the original one/two/three scenario)
  • Socket.IO timeout: binary events that encode to multiple Engine.IO packets

When an acknowledgement times out, Socket.IO already drops the packet from
its own send buffer. If the socket is still considered connected, the event
has already been written to the Engine.IO write buffer and was later flushed
once the transport became writable again.

Remove those unflushed Engine.IO packets on timeout, but keep a multi-packet
payload intact if any fragment was already handed to the transport.

Fixes socketio#4318

Co-authored-by: David <dyk1454683243-sudo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Timed out event is still buffered

2 participants