Quick answer: Add retries with backoff for transient failures, set timeouts so requests do not hang, degrade gracefully so a failed request does not crash the game, and protect state against failures, network errors are inevitable.
Network errors are inevitable in an online game, players have flaky connections. Here are the best ways to handle network errors.
Add Retries With Backoff
Handle network errors by adding retries with exponential backoff for transient failures, since many network errors are temporary (a brief drop, a server hiccup) and a retry succeeds. Backoff avoids hammering a struggling server.
Bugnet captures the network errors players hit, so you can see which failures are transient (worth retrying) and confirm that adding retries reduced the errors reaching players.
Set Timeouts So Requests Don't Hang
Handle network errors by setting timeouts on requests, so a hung connection does not make the game wait forever (which can look like a freeze), failing gracefully after a reasonable time instead. Timeouts prevent indefinite hangs.
Bugnet captures the freezes and errors from requests with no timeout (hanging the game), so you can see when missing timeouts cause problems and add them, then verify the hangs stopped.
Degrade Gracefully on Failure
Handle network errors by degrading gracefully when a request ultimately fails, catch the error, show the player an appropriate message, preserve their state, and recover or let them retry, rather than crashing or breaking. A network error should be an inconvenience, not a crash.
Bugnet captures the crashes from unhandled network errors (showing which failures crash the game), so you can see where to add graceful handling and verify per version the network-error crashes stopped.
Handle network errors by adding retries with backoff, setting timeouts, degrading gracefully, and protecting state against failures. Network errors are inevitable, so handle them gracefully.