sxyazi/yazi · error
Preloaders exceed the limit of {MAX_PRELOADERS}
Error message
Preloaders exceed the limit of {MAX_PRELOADERS} What it means
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.
Source
Thrown at yazi-config/src/plugin/preloaders.rs:27
use super::{MAX_PRELOADERS, Preloader};
use crate::{mix, plugin::{PreloaderArc, PreloaderMatcher, preloader_rev}};
#[derive(Debug, Default, Deserialize)]
pub struct Preloaders(ArcSwap<Vec<PreloaderArc>>);
impl Deref for Preloaders {
type Target = ArcSwap<Vec<PreloaderArc>>;
fn deref(&self) -> &Self::Target { &self.0 }
}
impl TryFrom<Vec<PreloaderArc>> for Preloaders {
type Error = anyhow::Error;
fn try_from(inner: Vec<PreloaderArc>) -> Result<Self> {
ensure!(
inner.len() <= MAX_PRELOADERS as usize,
"Preloaders exceed the limit of {MAX_PRELOADERS}"
);
Ok(Self(Self::reindex(inner).into_pointee()))
}
}
impl Preloaders {
pub fn matches<'a>(&self, file: &'a File, mime: &'a str) -> PreloaderMatcher<'a> {
self.matcher(Some(file), Some(mime))
}
fn matcher<'a, F, M>(&self, file: Option<F>, mime: Option<M>) -> PreloaderMatcher<'a>
where
F: Into<Cow<'a, File>>,
M: Into<Cow<'a, str>>,
{
PreloaderMatcher {View on GitHub (pinned to 5f901b886b)
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
Example fix
// before [[preloaders]] mime = "image/*" [[preloaders]] mime = "video/*" # ... dozens more entries exceeding the limit // after [[preloaders]] mime = "image/*" [[preloaders]] mime = "video/*" # kept only MAX_PRELOADERS entries; merged similar rules
Defensive patterns
Strategy: validation
Validate before calling
// before constructing Preloaders
if preloaders.len() > MAX_PRELOADERS as usize {
eprintln!("too many preloaders: {} > {MAX_PRELOADERS}", preloaders.len());
preloaders.truncate(MAX_PRELOADERS as usize);
}
let p = Preloaders::try_from(preloaders)?; Type guard
fn within_preloader_limit(v: &[PreloaderArc]) -> bool { v.len() <= MAX_PRELOADERS as usize } Prevention
- Count your [preloaders] entries when adding plugins
- Merge patterns into fewer preloaders
- Audit layered/generator configs for duplicate preloader blocks
When it happens
Trigger: Converting a Vec of PreloaderArc with more than MAX_PRELOADERS entries into a Preloaders value via TryFrom (used when deserializing the [preloaders] config section).
Common situations: 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.
Related errors
- Linemode must be between 1 and 20 characters long
- Invalid condition: {expr}
- Fetchers exceed the limit of {MAX_FETCHERS}
- at least one of `url` or `mime` must be specified
- Failed to get config directory
AI-assisted analysis of sxyazi/yazi@5f901b886b (2026-09-02).
Data as JSON: /api/errors/3a95dc5c50ef6aa8.
Report an issue: GitHub.