Server Error: client[procedureType] is not a function [ tRPC v10.45.2 OR v11 ] [ NextJS v14.1.X ]
Good Morning I am getting the above error when updating to the latest version of NextJS - 14.1.1 through 14.1.4.
The last release that doesn't cause this error is 14.1.0.
I have:
* ensured versions are the same on server and client.
* updated packages
* removed all node_modules and reinstalled.
*
* deleted
* deleted
* latest v18 and v20 of Node.js
It makes no sense at all. Its tRPC which is erroring but only when I upgrade NextJS past 14.1.
I can see that the tRPC request within the middleware runs as expected but its when trying to render a RSC component with a server side tRPC call in it is when I get the error.
full error:
The last release that doesn't cause this error is 14.1.0.
I have:
* ensured versions are the same on server and client.
* updated packages
* removed all node_modules and reinstalled.
*
pnpm store prune, * deleted
pnpm.lock and reinstalled.* deleted
.next folder* latest v18 and v20 of Node.js
It makes no sense at all. Its tRPC which is erroring but only when I upgrade NextJS past 14.1.
I can see that the tRPC request within the middleware runs as expected but its when trying to render a RSC component with a server side tRPC call in it is when I get the error.
full error:
Solution
I solved it.
This was due to having
I replaced it with
to discover this issue I followed the error to the code within
added some debugging like so:
From here I got a new error. Which was saying the
I removed the
This was due to having
use server at the top of my server.ts file for interacting with tRPC on the server side.I replaced it with
import server-onlyto discover this issue I followed the error to the code within
node_modulesnode_modules/.pnpm/@trpc+client@11.0.0-next.320_@trpc+server@11.0.0-next.320/node_modules/@trpc/client/dist/createTRPCClient.mjsadded some debugging like so:
From here I got a new error. Which was saying the
server.ts tRPC connecter was exporting a non-async function, which you cannot do if marking the file at the top with use server I removed the
use server from the top, replaced with use server-only removed the debugging lines added as shown above and it worked.