Skip to content

Commit b47c1fa

Browse files
ymc9claude
andcommitted
fix(orm): clear schemaCache before rebuilding registry in toJSONSchema
On a second call to toJSONSchema(), schemaRegistry.clear() emptied the registry but @cache()-decorated builders returned their cached ZodType without re-executing, so registerSchema() was never called and the serialized registry was empty. Fix by clearing schemaCache before schemaRegistry so all builders re-execute on the subsequent eager calls and re-register their schemas. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent bb8b2b4 commit b47c1fa

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

packages/orm/src/client/zod/factory.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,11 @@ export class ZodSchemaFactory<
201201
* before serialization.
202202
*/
203203
toJSONSchema() {
204-
// reset schema registry
204+
// Reset both the registry and the builder cache so that all eager calls
205+
// below re-execute their bodies and re-register schemas into the fresh registry.
206+
// Without clearing schemaCache, a second call to toJSONSchema() would hit cache
207+
// on every builder and never call registerSchema(), leaving the registry empty.
208+
this.schemaCache.clear();
205209
this.schemaRegistry.clear();
206210

207211
// Eagerly build schemas for included models so they are registered before serialization.

0 commit comments

Comments
 (0)