fix(server): update client lastActivityAt and lastPingAt on keepalive ping packets (#17) - #34
fix(server): update client lastActivityAt and lastPingAt on keepalive ping packets (#17)#34ghzhost wants to merge 1 commit into
Conversation
69e498c to
a099ef0
Compare
| const isPingPacket = packageID === pkg.serverPacketID.ping; | ||
|
|
||
| ws.packetCount = Number(ws.packetCount ?? 0) + 1; | ||
| ws.lastPacketAt = now; |
There was a problem hiding this comment.
⚠️ Bug: Setting lastPacketAt early zeroes out packet-interval metrics
The new ws.lastPacketAt = now; at server.ts:370 runs before line 378 reads previousPacketAt = Number(ws.lastPacketAt ?? 0). Since it was just overwritten with now, previousPacketAt === now, so intervalMs = Math.max(0, now - previousPacketAt) is always 0. This silently breaks lastPacketIntervalMs, minPacketIntervalMs, and recentPacketIntervalsMs for every non-ping packet — metrics consumed by the packet-usage ranking/anti-bot diagnostics in commands.ts (sendPacketUsageRanking). Fix by not overwriting lastPacketAt before the interval is computed: set it only inside the ping branch (the non-ping path already sets it at line 423).
Move lastPacketAt assignment into the ping branch so the non-ping interval calc still reads the previous packet's timestamp.:
ws.packetCount = Number(ws.packetCount ?? 0) + 1;
if (isPingPacket) {
ws.lastPacketAt = now;
ws.lastPingAt = now;
ws.lastActivityAt = now;
return;
}
Was this helpful? React with 👍 / 👎
CI failed: Integration tests failed due to missing seed files (like npcs.json) causing runtime file-not-found errors and cascading 500 status code test failures.Overview1 test failure pattern found across 1 job, causing the test suite to fail due to missing seed data files at runtime. FailuresMissing Seed Files / Database Seeding Failure (confidence: high)
Summary
Code Review
|
| Auto-apply | Compact |
|
|
Was this helpful? React with 👍 / 👎 | Gitar
Estado del CIEl check
Ambos fallos se reproducen en el historial de CI de Puede verificarse corriendo el suite de tests en |
|
Cierro esta porque la #17 ya quedo resuelta en Que pasoLa #17 junto cuatro PRs: #34, #50, #121 y #123. Se mergeo #121, de @franklincg, que tenia la issue asignada, y ademas resuelve el problema de una forma que las otras no. La solucion directa es hacer que el ping toque #121 separa las dos cosas: if (isPingPacket) {
ws.lastPingAt = now; // la conexion esta viva
return; // pero el jugador no hizo nada
}y despues, al decidir si expulsar, toma el maximo entre Contexto que no se veia desde afueraLos PRs que vienen de un fork quedan en Y Gracias por el laburo. Hay issues abiertas sin asignar: comenta con un plan concreto (que archivo, que funcion, como lo vas a verificar) y te la asigno. |
Problema resuelto (#17)
Cuando un cliente/jugador pasa la aplicación a segundo plano o bloquea la pantalla en dispositivos móviles, el cliente sigue enviando paquetes de periódicamente cada 10 segundos para mantener vivo el socket WebSocket. Sin embargo, en (), la lógica retornaba antes de actualizar al recibir paquetes de ping.
Como resultado, al cabo de 15 minutos (), el sweep de inactividad consideraba al jugador inactivo y lo expulsaba () aunque la conexión seguía viva.
Cambios realizados
Closes #17.