Describe the bug
We have an error in our production server. (I have not gained clearance to share the stack trace) that indicates errors object can be undefined.
TypeError
Cannot read properties of undefined (reading 'length')
My apologies, but we have not yet found a way to reliably reproduce this issue.
It may be caused by an imbalance between the versions of Zod and React Hook Form used in the project. However, for now, the error seems to originate from a single page and is not sporadic.
We are currently investigating further. For your reference, here are the versions of the relevant packages used in our project:
Describe the bug We have an error in our production server. (I have not gained clearance to share the stack trace) that indicates
errors
object can be undefined.https://github.com/react-hook-form/resolvers/blob/f7a4fd46af51a2a732c10ed652f5abfa532f4198/zod/src/zod.ts#L13
This error appeared as soon as the user navigated to the page. The error cause is still yet unknown.
But we suspect that the
error.errors
object may be undefined and not just null:https://github.com/react-hook-form/resolvers/blob/f7a4fd46af51a2a732c10ed652f5abfa532f4198/zod/src/zod.ts#L6
To Reproduce Steps to reproduce the behavior:
My apologies, but we have not yet found a way to reliably reproduce this issue.
It may be caused by an imbalance between the versions of Zod and React Hook Form used in the project. However, for now, the error seems to originate from a single page and is not sporadic.
We are currently investigating further. For your reference, here are the versions of the relevant packages used in our project:
Codesandbox link (Required) Include a codesandbox will help us to investigate the issue quicker.
Expected behavior
We expected no errors happening when we open the page.
Screenshots
Not applicable
Desktop (please complete the following information):
Additional context
The zod form schema is a rather complex form of an object inside an object. The innermost object have string fields. Looks something like:
Proposed Fix
Considering
isZodError
simply checks for theerrors
existence, should we make the function slightly more robust?