(Note that this answer makes some assumptions about what you mean by "desync")
It is NOT YOUR FAULT:
"Sync Errors" occur in multiplayer games because they are attempting to run an identical simulation on multiple machines. That means that a centralized server is not running the simulation, but instead with enforced latency and a queue of all user inputs, multiple clients are running an identical simulation all at the same time. A lot of games do this because it removes the overhead of server-side simulation and upkeep, and it also makes implementing instant-replay pretty easy. Ever notice how you can't get a terminal (crashes the game entirely) sync error in games that have dedicated servers? You can just reconnect and get right back in the action.
The downside is that if either of the clients' simulation no longer matches up with the others, the simulation is undefined and cannot continue. Which version of reality is the "right one"?
Here's a few reasons that a game can go out of sync:
- Random number generation that is not properly deterministic
- Floating point representation and math that is not properly standardized
- An error in the transport of input information between the clients
- ANY case where doing the same thing twice can produce two different results (critical hits?)
Now, you'll notice that there is virtually nothing you can do about this. It is the job of the game developers to ensure that sync errors do not occur. Unfortunately this is a hard problem to solve! Company of Heroes has been out since 2006 and has gone through two expansions and numerous patches and still has sync errors. Upgrading your internet and computer can help, but in the end if the software were written well enough sync errors would never happen even with sub-par hardware.
This is a pretty good article on the subject by a developer of Supreme Commander.