lucaspoffo / renet

Server/Client network library for multiplayer games with authentication and connection management made with Rust
Apache License 2.0
663 stars 68 forks source link

Possible race condition in the client/server test #54

Closed paul-english closed 1 year ago

paul-english commented 1 year ago

Copying the sending_and_receiving test to my project I see it failing most of the time. When I clone the repo, I can see an occasional failure if I just continue to run & run the tests. Is there any insight into what might help in debugging this or stepping through where there might be a race condition or system thing occurring that could lead to this?

Screen_Shot_2022-11-06_at_2 56 40_PM
lucaspoffo commented 1 year ago

I managed to reproduce once every ~20 tries. Seems to be that with 3 app.update() establishing a connection may fail since we don't control the system order for the server/client update. Updating a few more times seems to fix it: 7bb390f433757cf156607931394f7d63e7b78fab.

Can you check to see if it is fixed? I also added some trace logging to check the steps of the connection.

Shatur commented 1 year ago

But in your commit you updating it exactly 3 times. Maybe you wanted to write 0..4?

lucaspoffo commented 1 year ago

Right, was supposed to be just 10 to make sure, was testing the failed case. 7bb390f433757cf156607931394f7d63e7b78fab

Shatur commented 1 year ago

Maybe just wait for the connection by checking the client resource? If the test is fuzzy, using the exact number of updates doesn't look good...

lucaspoffo commented 1 year ago

Made the client loop until it's connected: b9d2e637c7b37daea62b3b9434ba39ca5862bb57