Describe the bug
When an errorFormatter is used, the response can be modified such that it satisfies the type of TRPCErrorShape from @trpc/server/rpc, but not the zod schema from this package, TRPCErrorSchema. This causes an error response to be interpreted as a successful, crashing the panel and giving a blank screen.
TLDR: When a formatted error is sent from tRPC, and fails the TRPCErrorSchema schema, the ProcedureForm uses Response when it should be using ErrorComponent.
To Reproduce
Steps to reproduce the behavior:
- use an
errorFormatter like I described above
- open trpc-ui panel
- trigger a procedure that returns an error
- page blanks
trpc-ui version: 1.0.15
trpc adapter used: express
Are you using superjson: no, but I don't think it matters
Expected behavior
The panel doesn't explode
Reproduction
https://stackblitz.com/edit/sb1-5tevmaui?file=src%2Fserver%2Ftrpc.ts
👍: I have this issue
👎: This issue has already been fixed
🚀: I would like to work on / be assigned this issue (@aidansunbury to get assigned)
Describe the bug
When an errorFormatter is used, the response can be modified such that it satisfies the type of
TRPCErrorShapefrom@trpc/server/rpc, but not the zod schema from this package,TRPCErrorSchema. This causes an error response to be interpreted as a successful, crashing the panel and giving a blank screen.TRPCErrorSchemacodeandhttpStatusoptional or have some defaultI feel like there is also a logic error here too
parseErroris called, the response is an error (it's called from the catch ofmeasureAsyncDuration{ isError: success }is dependent on if the zod schema parse succeededisErrorin theProcedureFormis interpreted as "did the request succeed or not?" and controls whether theErrorComponentor theResponsecomponent is renderedTLDR: When a formatted error is sent from tRPC, and fails the
TRPCErrorSchemaschema, theProcedureFormusesResponsewhen it should be usingErrorComponent.To Reproduce
Steps to reproduce the behavior:
errorFormatterlike I described abovetrpc-ui version: 1.0.15
trpc adapter used: express
Are you using superjson: no, but I don't think it matters
Expected behavior
The panel doesn't explode
Reproduction
https://stackblitz.com/edit/sb1-5tevmaui?file=src%2Fserver%2Ftrpc.ts
👍: I have this issue
👎: This issue has already been fixed
🚀: I would like to work on / be assigned this issue (@aidansunbury to get assigned)