Skip to content

chore: decrease the multipart threshold#265

Open
joeldierkes wants to merge 1 commit intomainfrom
chore/decrease-mp-threshold
Open

chore: decrease the multipart threshold#265
joeldierkes wants to merge 1 commit intomainfrom
chore/decrease-mp-threshold

Conversation

@joeldierkes
Copy link
Copy Markdown
Contributor

@joeldierkes joeldierkes commented Mar 13, 2026

Note

Medium Risk
Changes upload behavior by triggering multipart uploads more often and allowing smaller parts, which can increase request count and surface edge cases in client/server upload handling.

Overview
Multipart uploads are now used for smaller files by default by dropping DEFAULT_THRESHOLD from 100MB to 10MB.

It also lowers the minimum allowed partSize/threshold by changing MIN_PART_SIZE from 5MB to 1MB, allowing more (and smaller) parts per upload.

Written by Cursor Bugbot for commit 575bb7d. This will update automatically on new commits. Configure here.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Error messages hardcode "5MB" but minimum is now 1MB
    • Error message text now derives its human-readable minimum from MIN_PART_SIZE so the MB label matches the 1MB threshold.

Create PR

Or push these changes by commenting:

@cursor push 2b6197594c
Preview (2b6197594c)
diff --git a/src/lib/upload-file.ts b/src/lib/upload-file.ts
--- a/src/lib/upload-file.ts
+++ b/src/lib/upload-file.ts
@@ -11,6 +11,7 @@
 const DEFAULT_CONCURRENCY = 5;
 const DEFAULT_PART_SIZE = 100 * 1024 * 1024; // 100MB per part
 const MIN_PART_SIZE = 1 * 1024 * 1024; // 1MB minimum
+const MIN_PART_SIZE_LABEL = `${MIN_PART_SIZE / (1024 * 1024)}MB`;
 const MAX_PART_COUNT = 10_000;
 
 export interface PartUploadEvent {
@@ -29,9 +30,9 @@
 export interface MultipartUploadConfig {
   /** Maximum number of concurrent part uploads. Defaults to 5. */
   concurrency?: number;
-  /** File size threshold in bytes above which multipart upload is used. Minimum 5MB. Defaults to 100MB. */
+  /** File size threshold in bytes above which multipart upload is used. Minimum 1MB. Defaults to 100MB. */
   threshold?: number;
-  /** Size of each part in bytes. Minimum 5MB. Must not produce more than 10,000 parts. Defaults to 100MB. */
+  /** Size of each part in bytes. Minimum 1MB. Must not produce more than 10,000 parts. Defaults to 100MB. */
   partSize?: number;
   /** Called after each part is successfully uploaded. */
   onPartUpload?: (event: PartUploadEvent) => void;
@@ -72,11 +73,11 @@
     const partSize = multipartUpload?.partSize ?? DEFAULT_PART_SIZE;
 
     if (partSize < MIN_PART_SIZE) {
-      throw new Error(`partSize must be at least 5MB (${MIN_PART_SIZE} bytes), got ${partSize}`);
+      throw new Error(`partSize must be at least ${MIN_PART_SIZE_LABEL} (${MIN_PART_SIZE} bytes), got ${partSize}`);
     }
 
     if (threshold < MIN_PART_SIZE) {
-      throw new Error(`threshold must be at least 5MB (${MIN_PART_SIZE} bytes), got ${threshold}`);
+      throw new Error(`threshold must be at least ${MIN_PART_SIZE_LABEL} (${MIN_PART_SIZE} bytes), got ${threshold}`);
     }
 
     // Normalize the uploadable to a File object so we can inspect size

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

const DEFAULT_CONCURRENCY = 5;
const DEFAULT_PART_SIZE = 100 * 1024 * 1024; // 100MB per part
const MIN_PART_SIZE = 5 * 1024 * 1024; // 5MB minimum
const MIN_PART_SIZE = 1 * 1024 * 1024; // 1MB minimum
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Error messages hardcode "5MB" but minimum is now 1MB

Medium Severity

Changing MIN_PART_SIZE to 1MB without updating the hardcoded "5MB" in the error messages on lines 75 and 79 produces contradictory output. For example, the error now reads "partSize must be at least 5MB (1048576 bytes)" — but 1048576 bytes is 1MB, not 5MB. The human-readable label and the interpolated byte value disagree, confusing users.

Additional Locations (2)
Fix in Cursor Fix in Web

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.

1 participant