Skip to content

Commit bec0fab

Browse files
goffrieConvex, Inc.
authored and
Convex, Inc.
committed
Make MAX_USER_MODULES a knob (#36469)
GitOrigin-RevId: c750193b1c5160cc0ad8c7f25fcc3b70292b25bb
1 parent 64fccde commit bec0fab

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

crates/application/src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ use common::{
7878
knobs::{
7979
APPLICATION_MAX_CONCURRENT_UPLOADS,
8080
MAX_JOBS_CANCEL_BATCH,
81+
MAX_USER_MODULES,
8182
SNAPSHOT_LIST_LIMIT,
8283
},
8384
log_lines::LogLines,
@@ -413,9 +414,6 @@ use crate::metrics::{
413414
log_source_package_size_bytes_total,
414415
};
415416

416-
// The maximum number of user defined modules
417-
pub const MAX_USER_MODULES: usize = 10000;
418-
419417
pub struct ConfigMetadataAndSchema {
420418
pub config_metadata: ConfigMetadata,
421419
pub schema: Option<DatabaseSchema>,
@@ -2097,13 +2095,13 @@ impl<RT: Runtime> Application<RT> {
20972095
) -> anyhow::Result<BTreeMap<CanonicalizedModulePath, AnalyzedModule>> {
20982096
let num_dep_modules = modules.iter().filter(|m| m.path.is_deps()).count();
20992097
anyhow::ensure!(
2100-
modules.len() - num_dep_modules <= MAX_USER_MODULES,
2098+
modules.len() - num_dep_modules <= *MAX_USER_MODULES,
21012099
ErrorMetadata::bad_request(
21022100
"InvalidModules",
21032101
format!(
21042102
r#"Too many function files ({} > maximum {}) in "convex/". See our docs (https://docs.convex.dev/using/writing-convex-functions#using-libraries) for more details."#,
21052103
modules.len() - num_dep_modules,
2106-
MAX_USER_MODULES
2104+
*MAX_USER_MODULES
21072105
),
21082106
)
21092107
);
@@ -2112,7 +2110,7 @@ impl<RT: Runtime> Application<RT> {
21122110
// modules though. If we ever have crazy amount of dependency modules,
21132111
// throw a system errors so we can debug.
21142112
anyhow::ensure!(
2115-
modules.len() <= 2 * MAX_USER_MODULES,
2113+
modules.len() <= 2 * *MAX_USER_MODULES,
21162114
"Too many dependencies modules! Dependencies: {}, Total modules: {}",
21172115
num_dep_modules,
21182116
modules.len()

crates/common/src/knobs.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,10 @@ pub static MAX_PUSH_BYTES: LazyLock<usize> =
11491149
pub static MAX_ECHO_BYTES: LazyLock<usize> =
11501150
LazyLock::new(|| env_config("MAX_ECHO_BYTES", 128 * 1024 * 1024));
11511151

1152+
/// The limit on the number of user modules in a push bundle.
1153+
pub static MAX_USER_MODULES: LazyLock<usize> =
1154+
LazyLock::new(|| env_config("MAX_USER_MODULES", 10000));
1155+
11521156
/// Percentage of request traces that should sampled.
11531157
///
11541158
/// Sampling config is a JSON object with the following format:

0 commit comments

Comments
 (0)