react-hook-form: issue: "Maximum call stack size exceeded" in 7.55.0

Version Number

7.55.0

Codesandbox/Expo snack

https://codesandbox.io/p/devbox/smoosh-wave-4kj85l

Steps to reproduce

  1. Go to https://codesandbox.io/p/devbox/smoosh-wave-4kj85l
  2. Click on “Enabled”
  3. See error

We’re seeing several test failures since upgrading from 7.54.2 to 7.55.0. This one was the easiest to isolate and reproduce. It appears to be triggered by some combination of defaultValues, a normal watch call, and a watch subscription.

Expected behaviour

No error.

What browsers are you seeing the problem on?

Chrome

Relevant log output

RangeError
Maximum call stack size exceeded
get
https://4kj85l.csb.app/node_modules/react-hook-form/dist/index.esm.mjs:142:31
generateWatchOutput
https://4kj85l.csb.app/node_modules/react-hook-form/dist/index.esm.mjs:250:12
Object.callback
https://4kj85l.csb.app/node_modules/react-hook-form/dist/index.esm.mjs:270:54
Object.next
https://4kj85l.csb.app/node_modules/react-hook-form/dist/index.esm.mjs:1445:15
Object.next
https://4kj85l.csb.app/node_modules/react-hook-form/dist/index.esm.mjs:504:33
setValue
https://4kj85l.csb.app/node_modules/react-hook-form/dist/index.esm.mjs:1279:48
eval
/src/App.tsx:27:8

Code of Conduct

  • I agree to follow this project’s Code of Conduct

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 22
  • Comments: 22 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Hello, no news on this issue ? For now, I can’t upgrade because of this since 7.55.0 😕

We saw similar behavior with watch and 7.55.0. I didn’t get the error, but it would infinitely run the watch function and lock up the browser window. Reverting to 7.54.2.

I believe the issue has to do with a change in watch since both in the provided codesandbox repro and in my case removing usage of watch prevents the issue (maybe this PR which is in v7.55.0 ? or maybe this one)

I’m experiencing the same issue here and downgrading to 7.54.2 works - with 7.55.0 sometimes the app fully crashes the tab instead of showing maximum call stack size exceeded. Bummer since @hookform/resolvers ^5 has a peer dependency of ^7.55.0

Even with the dependency warning all is well - in some places I have to pass the generic to useForm (which I don’t need with @hookform/resolvers v5 - but the app runs)

Have also started seeing this as of today. Downgrading to 7.54.0 fixed it in the interim. Was previously on ^7.49.2 which auto increments minor versions to latest (compatible).

I will take a look later, but watch callback will get deprecated and removed in the next major release.

Bummer since @hookform/resolvers ^5 has a peer dependency of ^7.55.0

Even with the dependency warning all is well - in some places I have to pass the generic to useForm (which I don’t need with @hookform/resolvers v5 - but the app runs)

Yes. As I understand it, the only changes between @hookform/resolvers v4 and v5 are related to TypeScript types. (It made some improvements to type inference that depend in RHF ^7.55.0’s types.) Runtime behavior is unchanged, so, as long as people are willing to deal with any compile-time TypeScript issues, @hookform/resolvers 5.0.1 will work just fine with RHF 7.54.

@vineethvijayan314 Is there any chance that you’re getting upgraded to 7.55 inadvertently? (For example, the latest @hookform/resolvers depends on 7.55.) It may be worth checking your monorepo tooling, package lockfiles, and node_modules tree to verify that 7.54.2 is actually installed and that 7.55 isn’t creeping in somehow.

same issue, downgrading to react-hook-form@7.54.2

We encountered the same issue after upgrading from 7.51.4 to 7.54.4. Reverting to the previous working version resolved the problem.