Add sanity check to Sync packet handeling: to not remove connections the client didn't know about at time of packet construction#150
Open
nazzleflack wants to merge 2 commits intorancher:mainfrom
Open
Conversation
Sync packet handeling: to not remove connections the client didn't know about at time of packet construction
brandond
requested changes
Mar 12, 2026
Member
brandond
left a comment
There was a problem hiding this comment.
edit types.go and reduce SyncConnectionsInterval and SyncConnectionsTimeout to time.Second / 60 or similar
edit remotedialer/dummyserver to not return any http body (commenting out line 24)
execute dummy server and client examples
Can you perhaps add a test that does this? You may need to change some consts and functions to vars that can be modified by the test harness, but if this is reproducible - we should add a test to reproduce it.
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.
Issue: none
Problem
In case of multiple concurrent requests being processed remotedialer sometimes returns a
sync from clienterror to an api client.How to reproduce:
types.goand reduceSyncConnectionsIntervalandSyncConnectionsTimeouttotime.Second / 60or similarremotedialer/dummyserverto not return any http body (commenting out line24)dummyserverandclientexamplessometimes this works just fine, while other times a lot of
Get "http://localhost:8125": sync from clientmessages get returned by remotedialer.This is not the case if one sets
SyncConnections{Interval,Timeout}to very large numbers (= removing sync all together)- doing so fixes the error without leaving stale connections.Part of the problem (the part i address in this PR) was the implementation of the sync process.
Is was implemented in a way in which the client sends the server a list of all connection IDs the client still has open and the server closes the ones it has the client doesn't. This enabled the possibility of the client not yet knowing about a new connection, sending a
Syncpacket and the server then removing this connection before it had a chance of reaching the client.Solution
To resolve this specific case, I've added a additional field to the
SyncPacket. It sends the highest (and therefore latest) connection the client has received at time of crafting the packet. The server then only closes connections that are closed on the client AND older than the clients knowledge at time of crafting the packet.This DOES NOT completely eliminate the issue at hand though it greatly decreased the chance of it occurring.
I am convinced the rest of the issue is caused by the server sending connections out of order, i.e.
connectionIDsnot being linear when received or processed by the client, though I have not been able to come up with anything.CheckList