Skip to content

Panel can break with usage of an errorFormatter #81

Description

@ferm10n

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:

  1. use an errorFormatter like I described above
  2. open trpc-ui panel
  3. trigger a procedure that returns an error
  4. 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)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions