Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Answer 413 instead of cutting the connection when a request body is too large

Đã đóng
#3 2 bình luận 0 reaction 1 người được giao Xem trên GitHub

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

@PrathamAsrani đang làm issue này rồi.

Từ ngày 25/10/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

good first issue help wanted
The task

When a request body is larger than its limit (for example an import bigger than MAX_IMPORT_MB), the server should answer 413 Payload too large with its usual JSON error. Today it cuts the connection instead: curl fails with error 56, and the app can only show a generic network error, so the user never learns that the file was simply too big.

The cause is in readBody: after rejecting with a 413, it calls req.destroy(), which closes the socket before the error response can be sent. Stop buffering the body instead, let the 413 response go out, and close the connection only after it (for example with a Connection: close header).

Where to look
  • server/server.js, function readBody (around line 297)
  • tests/api.test.mjs, test import: replaces the map, validates ids, and enforces MAX_IMPORT_MB: it currently accepts either a 413 or a closed connection, which hides the bug

Reproduce: start the server with MAX_IMPORT_MB=1 and post a 1.3 MB JSON body to /api/import.

Done when
  • An oversized body gets a 413 response with {"error": "Payload too large"}
  • The test asserts exactly 413 (drop the connection closed alternative)
  • The server keeps working for the next request
  • npm test passes
Mentor

@0b3l1X-SolidGeeks

Ngôn ngữ chính
JavaScript
Star
0
Fork
1
Merge trung bình
14 phút
Pull request đã merge (30 ngày)
31

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 SolidGeeks/strata

Tất cả issue của SolidGeeks/strata

Issue tương tự

Thêm issue về JavaScript

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.