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.
POST /api/trpc/files.uploadFile?batch=1 500 in 879ms
⨯ ReferenceError: Cannot access 'createCaller' before initialization
at Module.createCaller (webpack-internal:///(rsc)/./src/server/api/root.ts:4:59)
at eval (webpack-internal:///(rsc)/./src/trpc/server.ts:33:65)
[...]) {
type: 'ReferenceError',
page: '/api/trpc/files.uploadFile'
}
POST /api/trpc/files.uploadFile?batch=1 500 in 879ms
⨯ ReferenceError: Cannot access 'createCaller' before initialization
at Module.createCaller (webpack-internal:///(rsc)/./src/server/api/root.ts:4:59)
at eval (webpack-internal:///(rsc)/./src/trpc/server.ts:33:65)
[...]) {
type: 'ReferenceError',
page: '/api/trpc/files.uploadFile'
}
TRPCClientError: Invalid response or stream interrupted
​​
cause: Error: Invalid response or stream interrupted
​​
columnNumber: 9
​​
data: undefinedfileName: "http://localhost:3000/_next/static/chunks/app/layout.js line 531 > eval"
​​
lineNumber: 54
​​
message: "Invalid response or stream interrupted"
​​
meta: undefined
​​
name: "TRPCClientError"
​​
shape: undefined
​​
stack: "TRPCClientError@webpack-internal:///(app-pages-browser)/./node_modules/@trpc/client/dist/TRPCClientError.mjs:54:9\nfrom@webpack-internal:///(app-pages-browser)/./node_modules/@trpc/client/dist/TRPCClientError.mjs:45:16\nunstable_httpBatchStreamLink/</</</<@webpack-internal:///(app-pag [...]
TRPCClientError: Invalid response or stream interrupted
​​
cause: Error: Invalid response or stream interrupted
​​
columnNumber: 9
​​
data: undefinedfileName: "http://localhost:3000/_next/static/chunks/app/layout.js line 531 > eval"
​​
lineNumber: 54
​​
message: "Invalid response or stream interrupted"
​​
meta: undefined
​​
name: "TRPCClientError"
​​
shape: undefined
​​
stack: "TRPCClientError@webpack-internal:///(app-pages-browser)/./node_modules/@trpc/client/dist/TRPCClientError.mjs:54:9\nfrom@webpack-internal:///(app-pages-browser)/./node_modules/@trpc/client/dist/TRPCClientError.mjs:45:16\nunstable_httpBatchStreamLink/</</</<@webpack-internal:///(app-pag [...]
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
luis
luisOP4w ago
Can someone help me? Testing out for 2 days now
AlexAnarcho
AlexAnarcho2w ago
running into the same issue and cant find the root cause
AlexAnarcho
AlexAnarcho2w ago
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 server
GitHub
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...
Want results from more Discord servers?
Add your server