tRPCttRPC
Powered by
ElvenE
tRPC•2y ago•
8 replies
Elven

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?
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Getting 413 error in Vercel when batching several queries (using Next pages router)
rodrigowplRrodrigowpl / ❓-help
3y ago
Types issues upgrading to v11, `never` when using t.router
mhMmh / ❓-help
16mo ago
Getting type error in v11 when trying to instantiate createTRPCQueryUtils
charliephanCcharliephan / ❓-help
3y ago