Skip to content

fix: ReadableStream not handling error properly#38081

Merged
kodiakhq[bot] merged 4 commits intodevelopfrom
fix/readablestream-error-handler
Jan 7, 2026
Merged

fix: ReadableStream not handling error properly#38081
kodiakhq[bot] merged 4 commits intodevelopfrom
fix/readablestream-error-handler

Conversation

@dougfabris
Copy link
Member

@dougfabris dougfabris commented Jan 6, 2026

Proposed changes (including videos or screenshots)

This PR addresses an issue where cancelling a file upload would cause an UnCaughtException (Error: aborted / ECONNRESET) on the server.

Introduced here: #37550

Issue(s)

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Bug Fixes
    • File upload errors from interrupted or aborted requests are now reliably caught and reported, preventing silent failures during uploads.
  • Tests
    • Added coverage to verify proper handling and propagation of aborted upload streams.
  • Chores
    • Recorded a patch-level changeset documenting the upload cancellation fix.

✏️ Tip: You can customize this high-level summary in your review settings.

CORE-1606

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Jan 6, 2026

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Jan 6, 2026

🦋 Changeset detected

Latest commit: 2f2a626

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 40 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/http-router Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/abac Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/license Patch
@rocket.chat/media-calls Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 6, 2026

Walkthrough

Adds explicit error handling to the request body ReadableStream used by getUploadFormData and test coverage to verify the function rejects when the request stream is aborted.

Changes

Cohort / File(s) Summary
Upload stream error handling
apps/meteor/app/api/server/lib/getUploadFormData.ts
Attaches an 'error' listener to Readable.fromWeb(request.body) that rejects the enclosing Promise on stream errors before piping into busboy.
Tests for aborted stream
apps/meteor/app/api/server/lib/getUploadFormData.spec.ts
Adds simulateError option to mock request factory and a test asserting getUploadFormData rejects with 'aborted' when the request stream emits an error.
Release metadata
.changeset/early-dots-leave.md
Adds a changeset entry documenting a patch fixing an uncaught exception when cancelling a file upload.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client
  participant ServerHandler as getUploadFormData
  participant ReadableBody as Readable.fromWeb(body)
  participant Busboy
  rect rgba(200,230,255,0.4)
    Client->>ServerHandler: POST multipart/form-data (request.body)
    ServerHandler->>ReadableBody: wrap request.body
    ReadableBody->>ServerHandler: attach 'error' listener
    ReadableBody->>Busboy: pipe() data
    Busboy->>ServerHandler: emit file/fields events
    ServerHandler->>ServerHandler: resolve Promise with parsed formData
  end
  rect rgba(255,220,220,0.35)
    Note over ReadableBody,ServerHandler: If ReadableBody emits 'error'
    ReadableBody-->>ServerHandler: 'error' (e.g., aborted)
    ServerHandler-->>Client: reject Promise with error
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • sampaiodiego

Poem

🐰 I hopped through pipes of stream and code,
Caught errors where they used to goad,
Now aborted hops are softly met,
Promises fail with no regret. 🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding proper error handling to ReadableStream in the getUploadFormData module.
Linked Issues check ✅ Passed The PR addresses the core objective from CORE-1606 by implementing error handling for aborted uploads to prevent server crashes.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the ReadableStream error handling issue: implementation in getUploadFormData.ts, test coverage in the spec file, and a corresponding changeset entry.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/readablestream-error-handler

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3f97fe5 and 6cce815.

📒 Files selected for processing (1)
  • .changeset/early-dots-leave.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (1)
.changeset/early-dots-leave.md (1)

1-5: Changeset format and content look good.

The changeset entry follows the standard format with the correct package scope, appropriate patch version bump (suitable for a bug fix), and a description that clearly communicates the fix aligns with the PR objectives.


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.

@dougfabris dougfabris added this to the 8.1.0 milestone Jan 6, 2026
@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 70.64%. Comparing base (f837394) to head (2f2a626).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #38081      +/-   ##
===========================================
+ Coverage    70.59%   70.64%   +0.05%     
===========================================
  Files         3145     3145              
  Lines       108761   108772      +11     
  Branches     19570    19573       +3     
===========================================
+ Hits         76780    76843      +63     
+ Misses       29967    29917      -50     
+ Partials      2014     2012       -2     
Flag Coverage Δ
e2e 60.15% <ø> (+0.06%) ⬆️
e2e-api 47.45% <ø> (+0.03%) ⬆️
unit 71.78% <91.66%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

KevLehman
KevLehman previously approved these changes Jan 6, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

📦 Docker Image Size Report

➡️ Changes

Service Current Baseline Change Percent
sum of all images 0B 0B 0B
account-service 0B 0B 0B
authorization-service 0B 0B 0B
ddp-streamer-service 0B 0B 0B
omnichannel-transcript-service 0B 0B 0B
presence-service 0B 0B 0B
queue-worker-service 0B 0B 0B
rocketchat 0B 0B 0B

📊 Historical Trend

---
config:
  theme: "dark"
  xyChart:
    width: 900
    height: 400
---
xychart
  title "Image Size Evolution by Service (Last 30 Days + This PR)"
  x-axis ["11/18 22:53", "11/19 23:02", "11/21 16:49", "11/24 17:34", "11/27 22:32", "11/28 19:05", "12/01 23:01", "12/02 21:57", "12/03 21:00", "12/04 18:17", "12/05 21:56", "12/08 20:15", "12/09 22:17", "12/10 23:26", "12/11 21:56", "12/12 22:45", "12/13 01:34", "12/15 22:31", "12/16 22:18", "12/17 21:04", "12/18 23:12", "12/19 23:27", "12/20 21:03", "12/22 18:54", "12/23 16:16", "12/24 19:38", "12/25 17:51", "12/26 13:18", "12/29 19:01", "12/30 20:52", "01/07 19:59 (PR)"]
  y-axis "Size (GB)" 0 --> 0.5
  line "account-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "authorization-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "ddp-streamer-service" [0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.00]
  line "omnichannel-transcript-service" [0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.00]
  line "presence-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "queue-worker-service" [0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.00]
  line "rocketchat" [0.35, 0.35, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.00]
Loading

Statistics (last 30 days):

  • 📊 Average: 1.5GiB
  • ⬇️ Minimum: 1.4GiB
  • ⬆️ Maximum: 1.6GiB
  • 🎯 Current PR: 0B
ℹ️ About this report

This report compares Docker image sizes from this build against the develop baseline.

  • Tag: pr-38081
  • Baseline: develop
  • Timestamp: 2026-01-07 19:59:31 UTC
  • Historical data points: 30

Updated: Wed, 07 Jan 2026 19:59:31 GMT

@dougfabris dougfabris marked this pull request as ready for review January 7, 2026 01:23
@dougfabris dougfabris requested a review from a team as a code owner January 7, 2026 01:23
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@dougfabris dougfabris added the stat: QA assured Means it has been tested and approved by a company insider label Jan 7, 2026
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Jan 7, 2026
@kodiakhq kodiakhq bot merged commit a1dee4e into develop Jan 7, 2026
78 checks passed
@kodiakhq kodiakhq bot deleted the fix/readablestream-error-handler branch January 7, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants