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

  1. Reduce the number of preloaders in [preloaders] to MAX_PRELOADERS or fewer
  2. Merge preloaders by combining url/mime patterns so one preloader covers several cases
  3. 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

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


AI-assisted analysis of sxyazi/yazi@5f901b886b (2026-09-02). Data as JSON: /api/errors/3a95dc5c50ef6aa8. Report an issue: GitHub.