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

Đang mở
#484 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
bun, typescript
Lĩnh vực
backend, networking

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
TypeScript
Star
7
Fork
2
Merge trung bình
1 ngày 17 giờ
Pull request đã merge (30 ngày)
17

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NanoForge-dev/Engine

Tất cả issue của NanoForge-dev/Engine

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.