T3 Stack: ReferenceError: Cannot access 'createCaller' before initialization
I want to use tRPC with mutations to upload a file in Next Js / T3 Stack with Supabase.
But no POST requests are working. The default 'post' mutation from the T3 stack template also does not work.
tRPC SHOULD config be correct, and should be able to run mutations, as I followed the installation guide. Because the default "post" also does not work, Supabase and the submission of FormData shouldn't be the problem.
What leads into the errors is the
createCaller()
:
```
// src/trpc/server.ts
...
const caller = createCaller(createContext);
export const { trpc: api, HydrateClient } = createHydrationHelpers<AppRouter>(
caller,
getQueryClient,
);
// src/server/api/root.ts
...
export const createCaller = createCallerFactory(appRouter);3 Replies
Can someone help me? Testing out for 2 days now
running into the same issue and cant find the root cause
so i figured it out after stumbeling upon this issue: https://github.com/t3-oss/create-t3-app/issues/1093 look for any circular imports, i.e. places you import the
api
from the server in and try to remove it. I did this by abstracting the logic to a new function that i now use in my procedures and elsewhere on the serverGitHub
bug: error - ReferenceError: Cannot access 'createTRPCRouter' befor...
Provide environment information System: OS: Windows 10 10.0.19045 CPU: (4) x64 Intel(R) Core(TM) i5-7300HQ CPU @ 2.50GHz Memory: 3.85 GB / 11.87 GB Binaries: Node: 16.16.0 - D:\Program Files\nodejs...