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

Aberta
#484 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
48/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
bun, typescript
Domínio
backend, networking

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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

Linguagem predominante
TypeScript
Estrelas
7
Forks
2
Merge médio
1d 17h
PRs com merge (30d)
17

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de NanoForge-dev/Engine

Todas as issues de NanoForge-dev/Engine

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.