Skip to content

fix: raise MAX_GENERIC_INSTANCES from 100 to 1000 to support Drizzle/Zod inference - #219

Open
techfreaque wants to merge 1 commit into
vercel-labs:mainfrom
techfreaque:fix-dynamic-max-generic
Open

fix: raise MAX_GENERIC_INSTANCES from 100 to 1000 to support Drizzle/Zod inference#219
techfreaque wants to merge 1 commit into
vercel-labs:mainfrom
techfreaque:fix-dynamic-max-generic

Conversation

@techfreaque

Copy link
Copy Markdown

Problem

MAX_GENERIC_INSTANCES (the cap that detects polymorphic recursion) was set to 100. Real-world TypeScript codebases using Drizzle ORM, Zod, and similar heavily-generic libraries routinely exceed this limit during type inference, producing spurious SC1000 (max instantiation depth) errors on valid programs.

Fix

lower-calls.ts: MAX_GENERIC_INSTANCES raised from 100 to 1000.

The cap still serves its purpose — infinite polymorphic recursion hits 1000 just as reliably as it hit 100. The difference is that legitimate deep generic stacks (Drizzle's select() return type, Zod's .parse() inference) now pass through without false positives.

Verification

A schema with 30+ Drizzle table joins and deep Zod inference compiles without SC1000. Artificially recursive types are still caught. packages/compiler builds clean.

The cap exists to detect POLYMORPHIC recursion (`f<T>` calling `f<T[]>`)
that would diverge forever. A real-world program with deeply generic
utility types (Drizzle ORM, Zod, tRPC) exhausts 100 instances during
normal non-recursive specialization — the compiler stops mid-lowering
and emits a diagnostic instead of a binary.

1000 is still a hard cap against runaway polymorphic recursion; it is
simply high enough that a ~600-file application with heavy generic usage
doesn't hit it spuriously.
@vercel

vercel Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

@techfreaque is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant