remotion-dev/remotion · error · TypeError
random() takes only one argument
Error message
random() takes only one argument
What it means
random(seed, dummy?) declares a second parameter only to detect old/mistaken calling conventions. If `dummy !== undefined` it throws immediately, catching callers who thought random() took a range (e.g. random(seed, max)). The function takes exactly one seed.
Source
Thrown at packages/core/src/random.ts:30
for (i = 0; i < str.length; i++) {
chr = str.charCodeAt(i);
hash = (hash << 5) - hash + chr;
hash |= 0; // Convert to 32bit integer
}
return hash;
}
export type RandomSeed = number | string | null;
/*
* @description A deterministic pseudo-random number generator. Pass in the same seed and get the same pseudorandom number.
* @see [Documentation](https://www.remotion.dev/docs/random)
*/
export const random = (seed: RandomSeed, dummy?: unknown) => {
if (dummy !== undefined) {
throw new TypeError('random() takes only one argument');
}
if (seed === null) {
return Math.random();
}
if (typeof seed === 'string') {
return mulberry32(hashCode(seed));
}
if (typeof seed === 'number') {
return mulberry32(seed * 10000000000);
}
throw new Error('random() argument must be a number or a string');
};
View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Remove the second argument: random(seed).
- Scale the result yourself: random(seed) * (max - min) + min.
Example fix
// before const v = random(seed, 100); // after const v = random(seed) * 100;
Defensive patterns
Strategy: type-guard
Validate before calling
const v = random(seed); // never pass a second argument
Type guard
// TypeScript already enforces (seed, dummy?: unknown); for JS: const callRandom = (seed: RandomSeed) => random(seed);
Prevention
- Call random() with exactly one argument.
- Scale ranges yourself: random(seed) * (max - min) + min.
- Delete any second positional arg copied from old examples.
When it happens
Trigger: Calling random(seed, 100), random(seed, min, max), or any form passing a second positional argument.
Common situations: Copy-pasting from a tutorial or library that used a different/older random API expecting a range argument.
Related errors
- random() argument must be a number or a string
- "samples" must be >= 1, but got ${samples}
- "${name}" must be a [number, number] tuple
- "${name}" must be a [number, number] tuple
- "${name}" must be greater than 0, but got ${JSON.stringify(v
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/b5ae2213fe9d5b8c.
Report an issue: GitHub.