Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Chiusa
#3 2 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@PrathamAsrani ci sta già lavorando.

Dal 25/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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

Lingua principale
JavaScript
Stelle
0
Fork
1
Merge medio
14m
PR unite (30g)
31

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di SolidGeeks/strata

Tutte le issue di SolidGeeks/strata

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.