Last 12 weeks · 259 commits
4 of 6 standards met
Use Nub 0.8.3 for workspace installs, scripts, benchmarks, hooks, CI, publishing and Vercel builds. Keep the existing lockfile and dependency resolutions, move workspace configuration into and , and remove the direct dependency. Third-party tools and built-package checks run through to preserve plain Node behavior. Publishing now requires a package version change, so this tooling migration cannot trigger a release. No package versions change. Consumer installation examples remain package-manager agnostic. The build, 8,106 tests across TypeScript 5.5/6/latest on Node 24, resolution checks, integrations, lint and actionlint pass locally. The Vercel install/build commands also pass locally and generate all 32 docs pages. Package publishing was checked with dry runs only.
Repro Wrapping the discriminator in (or ) is a common pattern for letting callers omit the tag when using a member schema directly () while still discriminating in the union. What changed Bisects to #6432 (shipped in 4.5.0): a wrapped discriminator ( set by /) now additionally claims as a discriminator value. With two or more wrapped members, they all claim and collide in the union's discriminator map. Why this is worse than a normal breaking change 1. The escapes . The discriminator map is built lazily, so construction succeeds and the throw happens at first parse — as a plain , not a . An app boots green and crashes on its first real input, even inside . 2. cannot catch it. The documented escape hatch for discriminator conflicts doesn't help: the map is evaluated before the fallback branch ( builds the map, then checks ), so the same throws with the option set. 3. It's a behavior change to a long-working pattern in a minor release, with no migration note. Verified on 4.4.3 (works, with and without ) and 4.5.0–4.5.4 (throws in both cases). Suggested direction Treat collided discriminator values as ambiguous instead of throwing while building the map: drop ambiguous values from the fast-path map (unambiguous literals keep O(1) routing), inputs whose discriminator resolves ambiguously fall through to when set, or produce a normal /"no matching discriminator" issue otherwise. That preserves #6432's intent ( can route to a uniquely-optional member) without turning a schema-shape property into a runtime crash that bypasses . Happy to help test a fix — we hit this with a 48-member discriminated union where every member uses a defaulted literal tag.
Compiling a large schema that contains runtime islands generates source that is mostly indentation, and that source stays resident in memory. On a real 162-branch discriminated union in our codebase with 212 islands, emits 34.1 MB of source of which 29.7 MB is leading whitespace, and the process retains 68 MB more heap on Node 24 (35 MB on Node 26) than before the compile. With the one-line fix below the same schema compiles to 5.5 MB of source and retains 13 MB. restores the indent level only when the callback returns normally: When a child generator throws inside an indented block, catches it and emits a runtime island, but the decrement never runs. Every line emitted after that point carries one extra indent level, and each further island adds another. Nothing reads the whitespace, but on Node 24 the generated source is retained with the function (see #6464), so it is live memory. Repro (zod 4.5.4, Node 24.14 and 26.8) opens an block, throws inside it, and everything after the island is shifted right: Fix Move the decrement into a : Branch with the change and an inline-snapshot test on the repro above, passing the full suite (linked since it seems I'm not permitted to contribute a pull request due to current repo configuration): https://github.com/colinhacks/zod/compare/main...aaronhipple:zod:fix/compile-doc-indent-leak?expand=1
Repository: colinhacks/zod. Description: TypeScript-first schema validation with static type inference Stars: 43846, Forks: 2177. Primary language: TypeScript. Languages: TypeScript (89.6%), MDX (9.3%), HTML (0.5%), JavaScript (0.4%), CSS (0.1%). License: MIT. Homepage: https://zod.dev Topics: runtime-validation, schema-validation, static-types, type-inference, typescript. Latest release: v4.5.4 (1w ago). Open PRs: 22, open issues: 36. Last activity: 6h ago. Community health: 85%. Top contributors: colinhacks, JacobWeisenburger, scotttrinh, pullfrog[bot], jeremyBanks, samchungy, igalklebanov, tmcw, noritaka1166, alexxander and others.