0

Using the t3-stack (Next, tRPC, Prisma, Next-auth, Typescript)

tRPC failed on undefined: TRPCError: Converting circular structure to JSON
    --> starting at object with constructor 'RequestHandler'
    |     property 'client' -> object with constructor 'PrismaClient'
    --- property '_fetcher' closes the circle

repo link: https://github.com/gabrielforster/my-portfolio (develop branch)

1 Answers1

0

Ran into the same error, in my case it was because I wasn't destructing my input value. Otherwise, it looks like it tries to serialize the entire context, including your PrismaClient etc.

Changing:

    .query(async (input) => {

to:

    .query(async ({ input }) => {

fixed my issue

  dataQuery: publicProcedure
    .input(QueryInputValidator)
    .output(QueryOutputValidator)
    .query(async ({ input }) => {
      return requestBackendEnv<QueryOutput>({
        url: "query/",
        method: "POST",
        body: input,
      });
    }),
Sean Breckenridge
  • 1,932
  • 16
  • 26