Skip to content

Fast-abort body size limit loses original error and may hang consumers #186

Description

@VikramAditya33

When processDecompressedChunk hits maxBodySize in fastAbort mode, the stream is never explicitly destroyed. It relies on uwsRes.close() eventually triggering the _onAbort callback, which:

  1. Overwrites the original 'Body size limit exceeded' error with 'Connection aborted'
  2. May leave awaiting consumers hanging briefly until the abort callback fires

Expected Behavior

  • req.buffer() / req.json() / req.text() should reject with Error: Body size limit exceeded even in fastAbort mode
  • The stream should be destroyed immediately with the correct error

Actual Behavior

  • The original error is lost because _onAbort unconditionally sets this.abortError = new Error('Connection aborted')
  • In test mocks (where close() does not trigger onAborted), the promise hangs forever

Proposed Fix

  1. In the else (fast-abort) branch, explicitly call this.destroy(this.abortError) so the error is preserved and consumers are unblocked immediately
  2. In the _onAbort callback, only set this.abortError if it isn't already set:
if (!this.abortError) {
  this.abortError = new Error('Connection aborted');
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions