Skip to content

fix: preserve body size limit error in fast-abort mode#198

Open
wahajahmed010 wants to merge 1 commit into
FOSSFORGE:mainfrom
wahajahmed010:fix/186-fast-abort-body-size-error
Open

fix: preserve body size limit error in fast-abort mode#198
wahajahmed010 wants to merge 1 commit into
FOSSFORGE:mainfrom
wahajahmed010:fix/186-fast-abort-body-size-error

Conversation

@wahajahmed010
Copy link
Copy Markdown

Summary

Fixes #186 — When processDecompressedChunk hits maxBodySize in fastAbort mode, the original Body size limit exceeded error was being overwritten by Connection aborted when the onAborted callback fired.

Problem

  1. In the size limit enforcement path (onChunk), uwsRes.close() was called without first setting this.abortError, so when onAborted fired, it unconditionally overwrote the error with Connection aborted
  2. In test mocks where close() does not trigger onAborted, pending promises could hang forever

Changes

  1. Set this.abortError to the Body size limit exceeded error before calling uwsRes.close() in the size limit path
  2. Guard this.abortError assignment in onAborted to only set it when not already set:
if (!this.abortError) {
  this.abortError = new Error("Connection aborted");
}

Testing

  • All 70 existing tests pass
  • Added 2 new test cases:
    • should preserve original error when size limit exceeded before abort
    • should preserve original error even when onAborted overwrites would occur

Both tests verify that buffer() rejects with Body size limit exceeded even after onAborted fires, not Connection aborted.

When processDecompressedChunk hits maxBodySize in fastAbort mode, the
stream was not explicitly destroyed and the original Body size limit
exceeded error was overwritten by Connection aborted when the
onAborted callback fired.

Changes:
- Set this.abortError before calling uwsRes.close() in the size limit
  path so the original error is preserved
- Guard abortError assignment in onAborted to only set it when not
  already set, preventing overwrite of the real error

Fixes FOSSFORGE#186
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6b98380a-95f6-4085-8a18-cfa4306277f7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant