remotion-dev/remotion · error · Error

Should not happen

Error message

Should not happen

What it means

Internal invariant in get-seeking-byte: byteToSeekTo was chosen as Math.max of the candidate seek bytes, but the subsequent timeInSeconds IIFE did not match any of the three sources (observed keyframe, cues, first media section). The comment 'Should not happen' marks it as a logic bug rather than a file-format issue.

Source

Thrown at packages/media-parser/src/containers/webm/seek/get-seeking-byte.ts:185

	});

	const timeInSeconds = (() => {
		if (byteToSeekTo === byteFromObservedKeyframe?.positionInBytes) {
			return Math.min(
				byteFromObservedKeyframe.decodingTimeInSeconds,
				byteFromObservedKeyframe.presentationTimeInSeconds,
			);
		}

		if (byteToSeekTo === byteFromCues?.byte) {
			return byteFromCues.timeInSeconds;
		}

		if (byteToSeekTo === byteFromFirstMediaSection) {
			return 0;
		}

		throw new Error('Should not happen');
	})();

	return {
		type: 'do-seek',
		byte: byteToSeekTo,
		timeInSeconds,
	};
};

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Retry the seek at a slightly different time to avoid the numeric coincidence.
  2. Parse linearly (no seek) to bypass the seek path entirely.
  3. Report the issue to the Remotion maintainers with the offending file and seek time, and use Mediabunny in the meantime.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await parseMedia({src: 'in.mkv', fields: {durationInSeconds: true}});
} catch (err) {
  if (err instanceof Error && err.message === 'Should not happen') {
    // internal invariant - avoid seeking, parse linearly instead
    await parseMedia({src: 'in.mkv', fields: {slowDurationInSeconds: true}});
  } else { throw err; }
}

Prevention

When it happens

Trigger: Reached when two of the candidate sources reported the same byte value but Math.max picked that value while the equality checks each compared against a possibly-undefined nullable field - a numeric coincidence or a regression in the seek logic. Practically rare and not user-fixable.

Common situations: A parser regression or an exotic file where two seek sources resolve to byte 0 simultaneously. Report rather than work around.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/2d1039c448784c9a. Report an issue: GitHub.