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:
@@ -64,7 +64,16 @@ internal static class Program
|
|||||||
|
|
||||||
while (await Tick.WaitForNextTickAsync())
|
while (await Tick.WaitForNextTickAsync())
|
||||||
{
|
{
|
||||||
world.Tick(TickRate);
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user