[Bug]: Oversized JSON requests destroy the socket before returning an error

Open
#494 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@dardmaansingh is already working on this.

Since Nov 16, 2026.

  • #496 by @dardmaansingh — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
typescript
Domain
api, backend

Research direction

Read src/server/signalling/utils.ts and trace how parseJsonBody() handles requests over 1 MB; then check the callers in src/server/signalling/handlers/rtc.ts and src/server/signalling/server.ts. Compare the JSON body behavior with the multipart upload issue #481 and verify that oversized requests can return a structured 413 response. Pull request #496 is already open for this issue.

Written by the indexing model from the issue text.

Description

bug
Bug Description

parseJsonBody() in src/server/signalling/utils.ts calls req.destroy() when a request exceeds the 1 MB limit, then rejects with Payload too large. The route handlers catch that rejection and try to send a JSON error response, but destroying the request also destroys the shared HTTP socket, so the client cannot receive the response. Oversized JSON requests therefore fail like the oversized file uploads described in #481, across endpoints that use this shared parser.

Steps to Reproduce
  1. Start Rein.
  2. Send a JSON POST body larger than 1 MB to a route that uses parseJsonBody(), such as POST /api/config from localhost.
  3. Observe that the connection is reset or the response is empty instead of receiving a structured error.
Expected Behavior

The server should stop buffering once the limit is reached and return 413 Payload Too Large with a clear JSON error. It should not destroy the request socket before the response can be delivered.

Code References
  • src/server/signalling/utils.ts: parseJsonBody() destroys the request after the byte limit is exceeded.
  • src/server/signalling/handlers/rtc.ts and src/server/signalling/server.ts: callers catch the rejection and attempt to respond with json().
Related
  • #481 covers the same socket-destruction behavior in multipart file uploads; this report covers JSON request bodies handled by the shared parser.
Dominant language
TypeScript
Stars
55
Forks
120
Avg merge
4d 5h
Merged PRs (30d)
24

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AOSSIE-Org/Rein

All issues in AOSSIE-Org/Rein

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.