-
Notifications
You must be signed in to change notification settings - Fork 5k
chore: zod 4 #38809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: zod 4 #38809
Conversation
Skn0tt
commented
Jan 16, 2026
- updates internal zod usage to zod v4, so we can leverage the built-in json schema converter and the prettifyErrors function
- ensures external support for both zod 3 and zod 4
- removes zod from utilsBundle so we don't ship it double
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| "target": "ESNext", | ||
| "noEmit": true, | ||
| "moduleResolution": "node", | ||
| "allowSyntheticDefaultImports": true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zod v4 needs this set because its declaration files use syntax that depends on it. without it, there's a type checking error. Users that have zod v4 installed will already have this, and users without zod v4 will not need it, so this change is fine.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| "@lowire/loop": "^0.0.23", | ||
| "@modelcontextprotocol/sdk": "^1.25.2", | ||
| "zod": "^3.25.76", | ||
| "zod": "^4.3.5", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please measure the bundle compilation time and the output size (e.g. ls -lh packages/playwright-core/lib/mcpBundleImpl/index.js) with old/new version. Rolling sdk and zod without any hack for sdk would leave in a bad state (see modelcontextprotocol/typescript-sdk#1313), let's make sure this doesn't regress because of the zod.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
old
886k
==== Running esbuild: packages/playwright-core/bundles/mcp/src/mcpBundleImpl.ts
Package contribution to bundle:
zod 119.9 KB 29.35%
ajv 102.0 KB 24.97%
@modelcontextprotocol/sdk 97.1 KB 23.77%
@lowire/loop 23.5 KB 5.75%
zod-to-json-schema 20.3 KB 4.98%
ajv-formats 9.9 KB 2.42%
fast-uri 9.3 KB 2.27%
@hono/node-server 7.7 KB 1.88%
eventsource 5.2 KB 1.27%
cross-spawn 2.9 KB 0.70%
content-type 1.9 KB 0.46%
eventsource-parser 1.8 KB 0.44%
isexe 1.5 KB 0.37%
which 1.4 KB 0.35%
json-schema-traverse 1.2 KB 0.30%
bytes 1.0 KB 0.26%
pkce-challenge 0.8 KB 0.20%
fast-deep-equal 0.7 KB 0.18%
path-key 0.2 KB 0.06%
shebang-command 0.2 KB 0.05%
shebang-regex 0.1 KB 0.01%
==== Done in 114 ms
new
666K
==== Running esbuild: packages/playwright-core/bundles/mcp/src/mcpBundleImpl.ts
Package contribution to bundle:
zod 374.6 KB 56.46%
ajv 102.2 KB 15.40%
@modelcontextprotocol/sdk 97.1 KB 14.64%
@lowire/loop 23.5 KB 3.54%
zod-to-json-schema 20.4 KB 3.07%
ajv-formats 9.9 KB 1.49%
fast-uri 9.3 KB 1.40%
@hono/node-server 7.7 KB 1.16%
eventsource 5.2 KB 0.79%
cross-spawn 2.9 KB 0.43%
content-type 1.9 KB 0.28%
eventsource-parser 1.8 KB 0.27%
isexe 1.5 KB 0.23%
which 1.4 KB 0.22%
json-schema-traverse 1.2 KB 0.18%
bytes 1.0 KB 0.16%
pkce-challenge 0.8 KB 0.12%
fast-deep-equal 0.7 KB 0.11%
path-key 0.2 KB 0.03%
shebang-command 0.2 KB 0.03%
shebang-regex 0.1 KB 0.01%
==== Done in 132 ms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The size is shrinking, yay!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i did something wrong when measuring. it now shows 411K on main, so the size actually grew
| if (!tool) | ||
| throw new Error(`Tool "${name}" not found`); | ||
| const parsedArguments = tool.schema.inputSchema.parse(rawArguments || {}); | ||
| const parsedArguments = tool.schema.inputSchema.parse(rawArguments || {}) as any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this used to be any, now it's unknown. we're casting it back so we can use it
tests/library/agent-perform.spec.ts
Outdated
| }); | ||
|
|
||
| test('retrieve a secret', async ({ context }) => { | ||
| // cannot get it to work reliably in CI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be skip then or is it failing locally too?
But I'd rather we made it work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's failing locally too, wrong comment. i'll make it work in a followup
| import { ZodTypeAny, z } from 'zod'; | ||
| // @ts-ignore this will be any if zod is not installed | ||
| type ZodInfer<T extends ZodTypeAny> = import('zod').infer<T>; | ||
| import * as z3 from 'zod/v3'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there zod/v3 in v3 zod?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, it'll be any. but the other one exists, so everything works :D
This comment has been minimized.
This comment has been minimized.
Test results for "MCP"4 failed 2826 passed, 121 skipped Merge workflow run. |
Test results for "tests 1"26 failed 4 flaky34567 passed, 691 skipped Merge workflow run. |