fix(network): bound frame size and per-peer packet queues on the TCP/UDP servers

Offen
#484 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
48/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
bun, typescript
Bereich
backend, networking

Rechercherichtung

Start with the TCP and UDP server entry points at modules/network/src/server/tcp.server.network.ts and modules/network/src/server/udp.server.network.ts, then trace the packet and candidate queues in peer-host.ts and packet.ts. Read how the existing signaling server sets maxPayloadLength and check for network tests covering frames and queue behavior. Done means frame size and per-peer queues, including pendingCandidates, are bounded, with tests demonstrating the limits.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug modules:network
Which package is this bug report for?

network

Issue description

The TCP and UDP Bun.serve calls keep Bun's default maxPayloadLength (about 16 MB); only SignalingServer sets one (signaling.server.network.ts:77). Per-client packet queues and pendingCandidates have no cap on count or bytes, and there is no rate limit. Each frame is copied twice and every typed packet is JSON.parsed even when nothing listens. One connected peer can exhaust server memory and CPU.

Where:

Evidence:

client.packets.get(frame.channel)?.push(frame.data);
webSocket.data.pendingCandidates.push(data.candidate);
if (payload) state.packets.push(payload);

grep -rn maxPayloadLength modules/network/src → only signaling.server.network.ts:77.

Suggested fix: Set maxPayloadLength (e.g. 64 KiB) on TCP and UDP, and cap per-peer queue length or bytes (drop the oldest or close the peer) and pendingCandidates.

Found during a code audit of main at be72076.

Code sample

No response

Versions
  • Engine main at be72076
  • pnpm 12.0.0, Node.js 26, Bun 1.3.14
Issue priority

High (immediate attention needed)

I have tested this issue on a development release

be72076

Vorherrschende Sprache
TypeScript
Sterne
7
Forks
2
Ø Merge
1 T. 17 Std.
Gemergte PRs (30 T.)
17

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus NanoForge-dev/Engine

Alle Issues in NanoForge-dev/Engine

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.