fix(qwik-router): use z.ZodType instead of removed z.Schema for zod 4 compatibility - #8898
Open
blakeley wants to merge 1 commit into
Open
fix(qwik-router): use z.ZodType instead of removed z.Schema for zod 4 compatibility#8898blakeley wants to merge 1 commit into
blakeley wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 2b017af The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@qwik.dev/core
@qwik.dev/router
eslint-plugin-qwik
create-qwik
@qwik.dev/optimizer
@qwik.dev/devtools
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #8896
zodQrldecided whether a resolved value was already a schema withobj instanceof z.Schema.Schemawas a zod-3-only alias forZodTypeand was removed in zod 4, so as soon as the router'szodspecifier resolves to a v4 copy — which is what happens in hoisted/deduped installs where the app depends on zod 4 —z.Schemaisundefinedand theinstanceofthrowsTypeError: Right-hand side of 'instanceof' is not callableon the server, turning everyzod$action into a 500. This is not a version-mixing problem: the schema object and theinstanceofcheck come from the same resolved zod module, the alias simply no longer exists.z.ZodTypeis exported by both zod 3 and zod 4 (in v3Schemawas literally an alias of it), so switching the runtime check — and the matchingz.Schematype positions inZodConstructor/ZodConstructorQRL— toz.ZodTypeis behaviour-preserving against the repo's pinned zod 3 and correct against zod 4. The API report and generated docs were regenerated withpnpm api.update; the only change there isz_2.Schema→z_2.ZodType.Minimal reproduction: https://github.com/blakeley/zod4-zodschema-crash — it 500s on the pinned router build and passes with this patch applied, so the fix is verified empirically and not just by inspection.
Relationship to #8887 (zod export tree-shaking): orthogonal. That PR changes how zod is imported/re-exported for bundle size and keeps
z.Schemaas the detection mechanism, so it does not address this crash; the two should merge cleanly in either order, and if #8887 lands first thez.Schemareference it preserves still needs this change.