Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,11 @@ function trackClientActivity(ws: RuntimeClient, packageID: number) {
const isPingPacket = packageID === pkg.serverPacketID.ping;

ws.packetCount = Number(ws.packetCount ?? 0) + 1;
ws.lastPacketAt = now;

@gitar-bot gitar-bot Bot Aug 21, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 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 👍 / 👎


if (isPingPacket) {
ws.lastPingAt = now;
ws.lastActivityAt = now;
return;
}

Expand Down
1 change: 1 addition & 0 deletions server/src/types/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ export type RuntimeClient = {
lastPacketIntervalMs?: number;
minPacketIntervalMs?: number;
lastActivityAt?: number;
lastPingAt?: number;
packetTypeCounts?: Record<string, number>;
nextMapClickAt?: number;
nextDoorToggleAt?: number;
Expand Down
Loading