The Arena workers ensure that the stateful multiplayer environment (which lives largely in Redis) remains clean and does not leak memory.
File Location: api/src/workers/arena/
Multiplayer Arena matches have a strict time limit (e.g., 10 minutes).
- Architecture: A simple
setIntervalheartbeat scanner that runs every 10 seconds. - Logic: It queries Redis for all active playing rooms. If it finds a room where
now >= endTime, it forces the match to finish (arenaMatchService.forceFinishMatch()). - Resilience: It hooks into
registerShutdownHandlerto cleanly clear its interval before the Node process exits.
When a match ends, the users are shown a post-game summary screen.
- Architecture: A standard BullMQ Worker listening to the
arena-cleanupqueue. - Logic: When an Arena match concludes, a delayed job is pushed to this queue (usually set to delay for 15-30 minutes). When the job fires, it purges all traces of that
roomIdfrom Redis memory (arenaRepository.deleteRoom(roomId)). - Concurrency: Set to
5to ensure multiple rooms can be cleaned simultaneously without choking Redis.