Conversation
When the "retries" option is set, emit() copies the current flags (compress, timeout) into the queued packet but did not clear them, so they were applied to the next emitted packets too, as long as the queue was not drained (socket not connected yet, or a previous packet still waiting for its acknowledgement).
DopestT
approved these changes
Oct 2, 2026
DopestT
approved these changes
Oct 2, 2026
DopestT
approved these changes
Oct 2, 2026
DopestT
approved these changes
Oct 2, 2026
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.
The kind of change this PR does introduce
Current behavior
With the
retriesoption,emit()hands the packet to_addToQueue(), which copiesthis.flagsinto the queued packet but never clears them.emit()then returns early, so the usualthis.flags = {}at the end is skipped. The flags are only reset when_drainQueue()happens to send something right away, which does not happen when the socket is not connected yet or when an earlier packet is still waiting for its ack.In that case a one-shot modifier like
compress(false)ortimeout()sticks to every following emit:Same thing once connected, if
socket.compress(false).emit("x")is called while another packet is pending: the nextemit()is sent uncompressed too.New behavior
The flags are cleared once they have been copied into the queued packet, so they only apply to that packet (including its retries), like they do without
retries.Other information (e.g. related issues)
I could not find an existing issue for this.
Two tests added to
test/retry.ts, one for the "not connected yet" case and one for the "previous packet pending" case. They check thecompressoption of each packet onpacketCreate. Without the change they fail withexpected [ false, false ] to sort of equal [ false, true ]andexpected [ true, false, false ] to sort of equal [ true, false, true ].npm test --workspace=socket.io-clientpasses (114 tests).