drizzle-team/drizzle-orm · error · RangeError

count exceeds max number of unique emails(${maxUniqueEmailsN

Error message

count exceeds max number of unique emails(${maxUniqueEmailsNumber}).

What it means

Error "count exceeds max number of unique emails(${maxUniqueEmailsNumber})." thrown in drizzle-team/drizzle-orm.

Source

Thrown at drizzle-seed/src/services/Generators.ts:1844

	static override readonly entityKind: string = 'GenerateEmail';

	private state: {
		genIndicesObj: GenerateUniqueInt;
		arraysToGenerateFrom: string[][];
	} | undefined;
	public override timeSpent: number = 0;
	public override isUnique = true;

	override init({ count, seed }: { count: number; seed: number }) {
		super.init({ count, seed });

		const domainsArray = emailDomains;
		const adjectivesArray = adjectives;
		const namesArray = firstNames;

		const maxUniqueEmailsNumber = adjectivesArray.length * namesArray.length * domainsArray.length;
		if (count > maxUniqueEmailsNumber) {
			throw new RangeError(
				`count exceeds max number of unique emails(${maxUniqueEmailsNumber}).`,
			);
		}

		const maxEmailLength = maxAdjectiveLength + maxFirstNameLength + maxEmailDomainLength + 2;
		if (this.stringLength !== undefined && this.stringLength < maxEmailLength) {
			throw new Error(
				`You can't use email generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxEmailLength}.`,
			);
		}

		const arraysToGenerateFrom = [adjectivesArray, namesArray, domainsArray];
		const genIndicesObj = new GenerateUniqueInt({
			minValue: 0,
			maxValue: maxUniqueEmailsNumber - 1,
		});
		genIndicesObj.init({ count, seed });

View on GitHub (pinned to b7862528fd)

Solutions

  1. Reduce the requested unique email count or drop the unique constraint.

When it happens

Trigger: Requesting more unique emails than the email generator can produce.

Common situations: Huge unique-email seed counts exceeding maxUniqueEmailsNumber.


AI-assisted analysis of drizzle-team/drizzle-orm@b7862528fd (2026-08-03). Data as JSON: /data/errors/af03e1aa47c4df1c.json. Report an issue: GitHub.