schollz/croc · error

Stored transfers can contain at most ${settings.maxFiles} fi

Error message

Stored transfers can contain at most ${settings.maxFiles} files

What it means

prepareStoredFiles() enforces settings.maxFiles: a stored transfer may contain at most that many files. The limit exists because each file adds manifest entries and per-file hashing time, and the server applies the same cap on creation.

Source

Thrown at web/src/protocol/stored.ts:297

      const { done, value } = await reader.read();
      if (done) break;
      await engine.sha256Update(handle, value);
    }
    return await engine.sha256Final(handle);
  } finally {
    reader.releaseLock();
  }
}

export async function prepareStoredFiles(
  selected: File[],
  settings: StoredSettings,
  callbacks: { onStatus?(status: string): void } = {},
  signal?: AbortSignal,
) {
  if (selected.length === 0) throw new Error("Choose at least one file");
  if (selected.length > settings.maxFiles) {
    throw new Error(`Stored transfers can contain at most ${settings.maxFiles} files`);
  }
  const total = selected.reduce((sum, file) => sum + file.size, 0);
  if (!Number.isSafeInteger(total) || total > settings.maxTransferBytes) {
    throw new Error(`Stored transfer exceeds the ${settings.maxTransferBytes} byte limit`);
  }
  const names = new Set<string>();
  const prepared: StoredPreparedFile[] = [];
  let firstChunk = 0;
  for (let index = 0; index < selected.length; index += 1) {
    const file = selected[index];
    const name = normalizeOutgoingFileName(file.name);
    if (names.has(name)) throw new Error(`Duplicate filename: ${name}`);
    names.add(name);
    callbacks.onStatus?.(`Hashing ${index + 1}/${selected.length}: ${name}`);
    const chunkCount = Math.ceil(file.size / storedChunkSize);
    prepared.push({
      file,
      name,

View on GitHub (pinned to e25f1bdc04)

Solutions

  1. Split the send into multiple stored transfers within the limit
  2. Pre-check at the UI layer and show the allowed count before submit
  3. If you operate the service and legitimately need more files, raise maxFiles in the settings served to clients (server must accept it too)

Example fix

// before
const prepared = await prepareStoredFiles(selected, settings);

// after
if (selected.length > settings.maxFiles) { alert(`At most ${settings.maxFiles} files`); return; }
const prepared = await prepareStoredFiles(selected, settings);
Defensive patterns

Strategy: validation

Validate before calling

if (selected.length > settings.maxFiles) { showError(`Stored transfers can contain at most ${settings.maxFiles} files`); return; }

Prevention

When it happens

Trigger: selected.length > settings.maxFiles, e.g. selecting 51 files when maxFiles is 50, or dropping an entire directory tree with thousands of files onto the picker.

Common situations: Users zipping-less workflows that drop whole folders; operators who lower maxFiles server-side while clients still show the old limit; batch sends that exceed the configured cap.

Related errors


AI-assisted analysis of schollz/croc@e25f1bdc04 (2026-08-15). Data as JSON: /api/errors/534ff6da1dda3778. Report an issue: GitHub.