Elven
Elven4mo ago

Error with v11 when using batching

I'm using the lastest version of v11. When I use the batch link I get an trpc inernal error when batched request are received. I'm using HonoJS, bun and v11. Stack trace:
TRPCError: Body already used
code: "PARSE_ERROR"
at new TRPCError (/usr/src/app/node_modules/@trpc/server/dist/unstable-core-do-not-import/error/TRPCError.mjs:51:9)
at /usr/src/app/node_modules/@trpc/server/dist/adapters/fetch/content-type/json/index.mjs:28:27
16 | if (!input) {
17 | return undefined;
18 | }
19 | return JSON.parse(input);
20 | }
21 | const body = opts.req.headers.get('content-type')?.startsWith('application/json') ? await opts.req.text() : '';
^
error: Body already used
at /usr/src/app/node_modules/@trpc/server/dist/adapters/fetch/content-type/json/index.mjs:21:111
at getRawProcedureInputOrThrow (/usr/src/app/node_modules/@trpc/server/dist/adapters/fetch/content-type/json/index.mjs:11:58)
at /usr/src/app/node_modules/@trpc/server/dist/adapters/fetch/content-type/json/index.mjs:37:36
at getInputs (/usr/src/app/node_modules/@trpc/server/dist/adapters/fetch/content-type/json/index.mjs:10:27)
at /usr/src/app/node_modules/@trpc/server/dist/adapters/fetch/fetchRequestHandler.mjs:104:26
at getInput (/usr/src/app/node_modules/@trpc/server/dist/adapters/fetch/fetchRequestHandler.mjs:103:25)
at /usr/src/app/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/resolveHTTPResponse.mjs:113:45
at getRawInputForBatch (/usr/src/app/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/resolveHTTPResponse.mjs:111:44)
at /usr/src/app/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/resolveHTTPResponse.mjs:136:30
TRPCError: Body already used
code: "PARSE_ERROR"
at new TRPCError (/usr/src/app/node_modules/@trpc/server/dist/unstable-core-do-not-import/error/TRPCError.mjs:51:9)
at /usr/src/app/node_modules/@trpc/server/dist/adapters/fetch/content-type/json/index.mjs:28:27
16 | if (!input) {
17 | return undefined;
18 | }
19 | return JSON.parse(input);
20 | }
21 | const body = opts.req.headers.get('content-type')?.startsWith('application/json') ? await opts.req.text() : '';
^
error: Body already used
at /usr/src/app/node_modules/@trpc/server/dist/adapters/fetch/content-type/json/index.mjs:21:111
at getRawProcedureInputOrThrow (/usr/src/app/node_modules/@trpc/server/dist/adapters/fetch/content-type/json/index.mjs:11:58)
at /usr/src/app/node_modules/@trpc/server/dist/adapters/fetch/content-type/json/index.mjs:37:36
at getInputs (/usr/src/app/node_modules/@trpc/server/dist/adapters/fetch/content-type/json/index.mjs:10:27)
at /usr/src/app/node_modules/@trpc/server/dist/adapters/fetch/fetchRequestHandler.mjs:104:26
at getInput (/usr/src/app/node_modules/@trpc/server/dist/adapters/fetch/fetchRequestHandler.mjs:103:25)
at /usr/src/app/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/resolveHTTPResponse.mjs:113:45
at getRawInputForBatch (/usr/src/app/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/resolveHTTPResponse.mjs:111:44)
at /usr/src/app/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/resolveHTTPResponse.mjs:136:30
For now i disabled it. Is there a better long term solution?
5 Replies
Nick
Nick4mo ago
Thanks, could you raise a bug ticket along with a small reproduction? I have a good idea what’s causing this and falling back to your last working release should be fine
Elven
Elven4mo ago
Thanks. I don't have a previously working release with it working, I've just set up trpc.
I'm not sure I will have time to make a repro in the next few days/weeks unfortunately. Will try when I can.
Nick
Nick4mo ago
If you can share details about your tRPC setup on the server that would be perfect
Alex / KATT 🐱
No stress about exact reproduction, but if you've just setup trpc maybe you could give us the steps you followed roughly? We just released some new features that seem to create issues in your setup even though we thought our tests covered all edge cases I was able to reproduce this and rolled back the code caused it 11.0.0-rc.351 should be good
Elven
Elven4mo ago
Thank you very much for the quick reaction !