fix(gameserver): drain the simulation queue on shutdown to avoid a hang #62
No reviewers
Labels
No labels
alpha:wave-0
alpha:wave-1
alpha:wave-2
alpha:wave-3
area:assets
area:combat
area:ecology
area:infra
area:render
area:scripting
area:ui
area:world
enhancement
epic
migration
post-alpha
roadmap
tech-debt
type:bug
type:chore
type:design
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
marco/IsoMmo!62
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/simulation-shutdown-hang"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A pre-existing flaky hang in CI (surfaced on #61, but unrelated to its content — #61 only touches the extractor + pack, and #60 with identical test code passed).
Root cause
Simulation.InvokeAsyncwrites work withTryWrite, which succeeds until the queue is completed. During shutdown there is a race: work written after the reader loop exits (on cancellation) but before the queue is completed sits undrained forever, so its awaiter — e.g. a disconnecting WebSocket handler mid-InvokeAsyncwhile the test host disposes — hangs indefinitely. Rare locally (tests pass in ~6s), but a slow/contended CI runner widens the race window and stalls the wholeGameServer.Testsjob (the "stuck 6 min" symptom).Fix
RunAsync'sfinallynow (1) completes the queue first, so any laterInvokeAsyncfaults fast instead of hanging, then (2) drains and runs whatever remained, so every awaiter settles. Regression test floodsInvokeAsyncacross cancellation and asserts all calls settle within a 5s guard.just lint-> 0 warnings.just test-> GameServer 139 green (6s).Definition of Done