{"record":{"id":"3a95dc5c50ef6aa8","repo":"sxyazi/yazi","slug":"preloaders-exceed-the-limit-of-max-preloaders","errorCode":null,"errorMessage":"Preloaders exceed the limit of {MAX_PRELOADERS}","messagePattern":"Preloaders exceed the limit of (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-config/src/plugin/preloaders.rs","lineNumber":27,"sourceCode":"\nuse super::{MAX_PRELOADERS, Preloader};\nuse crate::{mix, plugin::{PreloaderArc, PreloaderMatcher, preloader_rev}};\n\n#[derive(Debug, Default, Deserialize)]\npub struct Preloaders(ArcSwap<Vec<PreloaderArc>>);\n\nimpl Deref for Preloaders {\n\ttype Target = ArcSwap<Vec<PreloaderArc>>;\n\n\tfn deref(&self) -> &Self::Target { &self.0 }\n}\n\nimpl TryFrom<Vec<PreloaderArc>> for Preloaders {\n\ttype Error = anyhow::Error;\n\n\tfn try_from(inner: Vec<PreloaderArc>) -> Result<Self> {\n\t\tensure!(\n\t\t\tinner.len() <= MAX_PRELOADERS as usize,\n\t\t\t\"Preloaders exceed the limit of {MAX_PRELOADERS}\"\n\t\t);\n\n\t\tOk(Self(Self::reindex(inner).into_pointee()))\n\t}\n}\n\nimpl Preloaders {\n\tpub fn matches<'a>(&self, file: &'a File, mime: &'a str) -> PreloaderMatcher<'a> {\n\t\tself.matcher(Some(file), Some(mime))\n\t}\n\n\tfn matcher<'a, F, M>(&self, file: Option<F>, mime: Option<M>) -> PreloaderMatcher<'a>\n\twhere\n\t\tF: Into<Cow<'a, File>>,\n\t\tM: Into<Cow<'a, str>>,\n\t{\n\t\tPreloaderMatcher {","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-config/src/plugin/preloaders.rs#L9-L45","documentation":"This error is thrown by the TryFrom<Vec<PreloaderArc>> impl for Preloaders in yazi-config. Yazi enforces a hard cap (MAX_PRELOADERS) on how many preloaders can be configured, because each preloader is assigned an index used internally for scheduling; exceeding the cap would break that indexing. The ensure! macro fails the conversion with this message whenever the incoming vector's length exceeds the limit.","triggerScenarios":"Converting a Vec of PreloaderArc with more than MAX_PRELOADERS entries into a Preloaders value via TryFrom (used when deserializing the [preloaders] config section).","commonSituations":"Users with very large yazi.toml [preloaders] tables (many plugins registered to preload), or a config-merge/generator tooling that concatenates preloader lists from multiple sources.","solutions":["Reduce the number of preloaders in [preloaders] to MAX_PRELOADERS or fewer","Merge preloaders by combining url/mime patterns so one preloader covers several cases","Check for duplicate preloader registrations from layered configs and dedupe"],"exampleFix":"// before\n[[preloaders]]\nmime = \"image/*\"\n\n[[preloaders]]\nmime = \"video/*\"\n# ... dozens more entries exceeding the limit\n// after\n[[preloaders]]\nmime = \"image/*\"\n\n[[preloaders]]\nmime = \"video/*\"\n# kept only MAX_PRELOADERS entries; merged similar rules","handlingStrategy":"validation","validationCode":"// before constructing Preloaders\nif preloaders.len() > MAX_PRELOADERS as usize {\n    eprintln!(\"too many preloaders: {} > {MAX_PRELOADERS}\", preloaders.len());\n    preloaders.truncate(MAX_PRELOADERS as usize);\n}\nlet p = Preloaders::try_from(preloaders)?;","typeGuard":"fn within_preloader_limit(v: &[PreloaderArc]) -> bool { v.len() <= MAX_PRELOADERS as usize }","tryCatchPattern":null,"preventionTips":["Count your [preloaders] entries when adding plugins","Merge patterns into fewer preloaders","Audit layered/generator configs for duplicate preloader blocks"],"tags":["config","limit-exceeded","preloaders"],"backgroundTag":"config-limit-exceeded","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}