mifi/lossless-cut · error · UserFacingError
Tried to create too many segments (max {{maxSegmentsAllowed}
Error message
Tried to create too many segments (max {{maxSegmentsAllowed}}.) What it means
Thrown by loadCutSegments() when segments.length exceeds maxSegmentsAllowed (imported from util/constants). It protects the UI and memory from an pathologically large segment list that would make the timeline and segment list unusable. The error message is i18n-interpolated with the actual limit so the user knows the threshold.
Source
Thrown at src/renderer/src/hooks/useSegments.tsx:172
clearSegColorCounter();
safeSetCutSegments([]);
}, [clearSegColorCounter, safeSetCutSegments]);
const shuffleSegments = useCallback(() => safeSetCutSegments((existingSegments) => [
...existingSegments.filter((s) => !s.selected),
...shuffleArray(existingSegments.filter((s) => s.selected)),
]), [safeSetCutSegments]);
// todo combine with safeSetCutSegments?
const loadCutSegments = useCallback(({ segments, append, clampDuration, getNextCurrentSegIndex }: {
segments: SegmentBase[],
append: boolean,
clampDuration?: number | undefined,
getNextCurrentSegIndex?: (newEdl: SegmentBase[]) => number,
}) => {
if (segments.length === 0) throw new UserFacingError(i18n.t('No valid segments found'));
if (segments.length > maxSegmentsAllowed) throw new UserFacingError(i18n.t('Tried to create too many segments (max {{maxSegmentsAllowed}}.)', { maxSegmentsAllowed }));
if (!append) clearSegColorCounter();
safeSetCutSegments((existingSegments) => {
const needToAppend = append && !isInitialSegment(existingSegments);
let newSegments = segments.map((segment, i) => createIndexedSegment({ segment, incrementCount: needToAppend || i > 0 }));
if (needToAppend) newSegments = [...existingSegments, ...newSegments];
if (getNextCurrentSegIndex) setCurrentSegIndex(getNextCurrentSegIndex(newSegments));
return newSegments;
}, clampDuration);
}, [clearSegColorCounter, createIndexedSegment, safeSetCutSegments]);
const detectSegments = useCallback(async ({ name, workingText, errorText, fn }: {
name: string,
workingText: string,
errorText: string,
fn: (onSegmentDetected: (seg: SegmentBase) => void) => Promise<{ ffmpegArgs: string[] }>,
}) => {View on GitHub (pinned to 3b9a59c288)
Solutions
- Reduce the number of segments in the source file to at or below maxSegmentsAllowed before importing.
- Split the import into multiple smaller EDLs.
- If the limit is genuinely too low for the use case, raise maxSegmentsAllowed in util/constants (mind memory/perf).
- Pre-count rows and warn the user before attempting the import.
Example fix
// before
loadCutSegments({ segments, append });
// after
if (segments.length > maxSegmentsAllowed) {
toast.error(`Too many segments (${segments.length}). Limit is ${maxSegmentsAllowed}.`);
return;
}
loadCutSegments({ segments, append }); Defensive patterns
Strategy: validation
Validate before calling
import { maxSegmentsAllowed } from './util/constants';
if (segments.length > maxSegmentsAllowed) {
throw new Error(`Refusing to import ${segments.length} segments (limit ${maxSegmentsAllowed}). Split the file or raise the limit.`);
} Type guard
const withinSegmentLimit = (segs: unknown): segs is SegmentBase[] => Array.isArray(segs) && segs.length <= maxSegmentsAllowed;
Try / catch
try {
loadCutSegments({ segments, append });
} catch (err) {
if (err instanceof UserFacingError && /too many segments/.test(err.message)) {
showError(`Too many segments (${segments.length}). Limit is ${maxSegmentsAllowed}.`);
return;
}
throw err;
} Prevention
- Pre-count rows in the source EDL/CSV and warn before importing if it exceeds the limit.
- Split large cut lists into multiple smaller EDLs.
- Raise maxSegmentsAllowed only after considering memory/performance impact.
- Filter out unwanted segments (e.g. below a duration threshold) before import.
When it happens
Trigger: Importing an EDL/CSV that contains more than maxSegmentsAllowed rows; a programmatic generator producing an unbounded number of segments; a malformed file whose structure caused row explosion (e.g. one row per frame).
Common situations: A huge CSV (thousands of rows) from a detection tool (scene detection, ad detection); an EDL with per-frame cuts; a generator script run with too many entries; merging many EDLs together.
Related errors
- No valid segments found
- Segment start time must precede end time
- Cannot find any keyframe within 60 seconds of frame {{time}}
- No rows found
- Invalid start or end value. Must contain a number of seconds
AI-assisted analysis of mifi/lossless-cut@3b9a59c288 (2026-08-12).
Data as JSON: /api/errors/9a3b695f1bd8a658.
Report an issue: GitHub.