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.
*
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:Jump to solution
I solved it.
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-only
to discover this issue I followed the error to the code within node_modules
node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@trpc/client/dist/createTRPCClient.mjs
...12 Replies
Here is my server link:
have you tried deleting the .next folder?
hey erik. yes i have
changing trpc versions (to latest v11) pruning pnpm
deleting all node_modules and reinstalling
it happens on every version after next v14.1.0
link to repo: https://github.com/lwears/ReelScore
GitHub
GitHub - lwears/ReelScore: Movies and TV Ratings
Movies and TV Ratings. Contribute to lwears/ReelScore development by creating an account on GitHub.
hey sorry for the delay i just took a look at your project and i think it runs as expected...
Hey @erik.gh thanks. But i think the latest pushed version is downgraded to nextjs v14.1.0
its when i upgrade next it starts erroring
no wait i didnt push it...
ok so it works for you as expected? could you actually get a the /movies page up for example?
hm i just did a fresh git clone to a new folder and tested again and still getting the same error
done a
pnpm store prune
as well
ive been investigating this with a senior friend of mine just now.
It makes no sense at all. Its tRPC which is erroring but only when I upgrade NextJS past 14.1.
We can see that the tRPC request within the middlware runs as expected but its when trying to render a RSC component with a tRPC call in itSolution
I solved it.
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-only
to discover this issue I followed the error to the code within node_modules
node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@trpc/client/dist/createTRPCClient.mjs
added 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 import server-only
removed the debugging lines added as shown above and it worked.@erik.gh Thanks for your help. I solved it anyway. see the above ^
oh that's interesting happy you got it to work