fix(game-server): survive bad-packet exceptions in tick loop
Build Game Server / build (push) Successful in 17s
Build Game Server / build (push) Successful in 17s
Wrap world.Tick in try/catch so an incompatible/misaligned client packet logs an error and the server keeps running (stable R&D bench). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -63,9 +63,18 @@ internal static class Program
|
||||
Logger.Information("Server listening on :{Port}. Waiting for players…", port);
|
||||
|
||||
while (await Tick.WaitForNextTickAsync())
|
||||
{
|
||||
try
|
||||
{
|
||||
world.Tick(TickRate);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// A misaligned/incompatible client packet must not kill the whole server
|
||||
// (R&D: the client's exact net version isn't matched yet). Log and continue.
|
||||
Logger.Error(ex, "Tick error (bad packet?) — continuing");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Logger.Information("Shutting down");
|
||||
|
||||
Reference in New Issue
Block a user