-
Notifications
You must be signed in to change notification settings - Fork 97
Description
When calling a unary method using @connectrpc/connect-web in a React server component in Next.js 15, you will always get the following error:
Failed to generate cache key for https://demo.connectrpc.com/connectrpc.eliza.v1.ElizaService/Say
To Reproduce
node 22
git clone --depth 1 --branch main https://github.com/connectrpc/examples-es.git
cd examples-es
git fetch --depth 1 origin 2b0dee9557f3e596e3dee326a173f443c4a8663a
git checkout 2b0dee9557f3e596e3dee326a173f443c4a8663a
cd nextjs
npm install
npm run generate
npm run start
Once the server is running:
- Open http://localhost:3000/react-server-actions in your browser
- Enter some text in the input field
- Click send or press enter
Additional context
Error seems to be from:
https://github.com/vercel/next.js/blob/v15.0.2/packages/next/src/server/lib/patch-fetch.ts#L536
The source of the issue appears to be that the cache key computation doesn't account for the fetch body being a Uint8Array:
https://github.com/vercel/next.js/blob/v15.0.2/packages/next/src/server/lib/incremental-cache/index.ts#L265
I don't know why Next14 didn't have this issue but 15 does. I thought POST fetches are still supposed to bypass cache completely?