zod: Zod v3.20.2 causing stalled build in CRA project

Started using Zod in a create-react-app project in combination with react-hook-form. Everything works fine except building the project.

No error is thrown, the build simply freezes and is stalled. When running npm run build --verbose it just pretty much stops completely after the first initial logs that happen within approx. 20ms.

It seems to be a problem with the, at this time, latest version v3.20.2. After downgrading Zod to v3.19.1, it builds normally.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 8
  • Comments: 15 (1 by maintainers)

Commits related to this issue

Most upvoted comments

I’ve been experiencing a similar performance issue.

TypeScript autocompletion is extremely slow in VS Code when zod@3.20.2 package is installed, the CPU usage spikes to 100% and it usually takes 3-4 seconds to load the suggestions. After removing zod or downgrading it to v3.19.1 the issue is gone. You can see more details in the related stackoverflow post I created: https://stackoverflow.com/questions/74881472/slow-typescript-autocompletion-in-vs-code-for-zod.

It’s worth mentioning that this issue also occurs in Webstorm, so I’m convinced it’s not VSCode-related.

Okay, I found the cause of all the problems. It seems to be TSDX 0.14.1, which can cause some weird issues with TypeScript error check because it doesn’t support the latest version of TS and hasn’t been updated in 2 years (!) In my case, the solution was to switch to DTS-CLI, which runs and builds super fast without any problems with Zod.

I hope this has helped someone.

v30.20.6 still has the mentioned bugs. The build just hangs forever and intellisense (webstorm) becomes highly unresponsive.

@colinhacks You are still unconvinced it should have been a semver major 😃?