-
Notifications
You must be signed in to change notification settings - Fork 3
feat: let the server decide the maximum bundle size #365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,6 +14,10 @@ use tower_api::apis::Error; | |||||||||||||||||||||||||||||||||||||
| use tower_api::apis::ResponseContent; | ||||||||||||||||||||||||||||||||||||||
| use tower_api::models::DeployAppResponse; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| /// Advisory only: the server enforces the actual bundle-size limit and reports | ||||||||||||||||||||||||||||||||||||||
| /// it in its error response when a bundle is too large. | ||||||||||||||||||||||||||||||||||||||
| pub const LARGE_PACKAGE_WARNING_THRESHOLD: u64 = 500 * 1024 * 1024; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| pub async fn upload_file_with_progress( | ||||||||||||||||||||||||||||||||||||||
| out: &output::Out, | ||||||||||||||||||||||||||||||||||||||
| api_config: &Configuration, | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -36,13 +40,11 @@ pub async fn upload_file_with_progress( | |||||||||||||||||||||||||||||||||||||
| let metadata = file.metadata().await?; | ||||||||||||||||||||||||||||||||||||||
| let file_size = metadata.len(); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // Check if bundle size exceeds the maximum allowed size | ||||||||||||||||||||||||||||||||||||||
| if file_size > tower_package::MAX_PACKAGE_SIZE { | ||||||||||||||||||||||||||||||||||||||
| if file_size > LARGE_PACKAGE_WARNING_THRESHOLD { | ||||||||||||||||||||||||||||||||||||||
| let size_mb = file_size as f64 / (1024.0 * 1024.0); | ||||||||||||||||||||||||||||||||||||||
| let max_mb = tower_package::MAX_PACKAGE_SIZE as f64 / (1024.0 * 1024.0); | ||||||||||||||||||||||||||||||||||||||
| out.die(&format!( | ||||||||||||||||||||||||||||||||||||||
| "Your App is too big! ({:.2} MB) exceeds maximum allowed size ({:.0} MB). Please consider reducing app size by removing unnecessary files or import_paths in the Towerfile.", | ||||||||||||||||||||||||||||||||||||||
| size_mb, max_mb | ||||||||||||||||||||||||||||||||||||||
| out.write(&format!( | ||||||||||||||||||||||||||||||||||||||
| "Warning: Your app package is large ({:.2} MB). The server may reject it depending on its configured maximum bundle size. You can reduce app size by removing unnecessary files or import_paths in the Towerfile.\n", | ||||||||||||||||||||||||||||||||||||||
| size_mb | ||||||||||||||||||||||||||||||||||||||
| )); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+43
to
49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Use a consistent size unit in the warning. Line 44 calculates MiB using Proposed fix- let size_mb = file_size as f64 / (1024.0 * 1024.0);
+ let size_mib = file_size as f64 / (1024.0 * 1024.0);
out.write(&format!(
- "Warning: Your app package is large ({:.2} MB). The server may reject it depending on its configured maximum bundle size. You can reduce app size by removing unnecessary files or import_paths in the Towerfile.\n",
- size_mb
+ "Warning: Your app package is large ({:.2} MiB). The server may reject it depending on its configured maximum bundle size. You can reduce app size by removing unnecessary files or import_paths in the Towerfile.\n",
+ size_mib📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Keep the warning threshold private.
Line 19 declares
LARGE_PACKAGE_WARNING_THRESHOLDaspub. The PR objective says this value must remain private. Removepubso callers cannot depend on the client-only warning threshold.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents