[BUG] Type Error when used defineMetadataSchema and handleServerError together. #333
Open
2 tasks done
Labels
bug
Something isn't working
Are you using the latest version of this library?
Is there an existing issue for this?
Describe the bug
I am trying to log errors to Posthog using handleServerError, and it worked. But I needed a few more details, like the file and action name. I think using metadata can be a good option.
So created a new action client using this code.
This works and I can use the metadata values but the types have some issues.
If I don't add utils in this line handleServerError: (error, utils) => {, then types work correctly. But if I add utils then types don't work. Everywhere where I am pass metadata starts to give errors. I have attached a video please take a look.
Recording.2025-03-13.081706.mov
Reproduction steps
Create a new action client with two functions handleServerError and defineMetadataSchema and use metadata inside the handleServerError function.
Expected behavior
The types should work fine even when I use metadata inside the handleServerError function.
Link to a minimal reproduction of the issue
https://github.com/yourcodebuddy-in/next-safe-action-bug.git
Operating System
Windows 11
Library version
7.10.4
Next.js version
15.2.2
Node.js version
22.13.1
Additional context
No response
The text was updated successfully, but these errors were encountered: