Nitro and tRPC in vercel-edge

Hey there! I hope this is the right place to ask for help. I am trying to deploy an application with Nitro and tRPC with the vercel-edge preset. I am getting a weird proxy error when I deploy it without making any changes to how tRPC is handled.
TypeError: 'getOwnPropertyDescriptor' on proxy: trap reported non-configurability for property 'setTimeout' which is either non-existent or configurable in the proxy target
at (index.mjs:1:1261145)
at (index.mjs:1:1270611)
at (index.mjs:1:1272087)
at (index.mjs:1:1246628)
at (index.mjs:1:1271597)
at (index.mjs:1:1273439)
at (__nitro:middleware.js:1:17)
TypeError: 'getOwnPropertyDescriptor' on proxy: trap reported non-configurability for property 'setTimeout' which is either non-existent or configurable in the proxy target
at (index.mjs:1:1261145)
at (index.mjs:1:1270611)
at (index.mjs:1:1272087)
at (index.mjs:1:1246628)
at (index.mjs:1:1271597)
at (index.mjs:1:1273439)
at (__nitro:middleware.js:1:17)
I think I need to use the fetchRequestHanlder as described in the tRPC documentation for Fetch / Edge Runtimes https://trpc.io/docs/server/adapters/fetch They provide examples for Next.js, Remix, and SoldStart, but not Nuxt/Nitro. Nitro uses IncommingMessage and ServerResponse, while the fetchRequestHandler expects a Request and returns a Response. My initial, naive approach was to simply map back and forth between the two using these utilities I found for astro: https://github.com/withastro/astro/blob/2dca81bf2174cd5c27cb63cb0ae081ea2a1ac771/packages/integrations/vercel/src/serverless/request-transform.ts#L2 But again I am getting errors that seem to stem from Nitro using node-fetch under the hood? I am not experienced enough with the edge runtime or nitro to completely understand why it would not work and what needs to happen to make tRPC and Nitro on edge work together. If anyone has any pointers or if anyone has a repo of a Nuxt/Nitro project that uses tRPC on the edge that would be awesome! Thanks already for your help!
Fetch / Edge Runtimes Adapter | tRPC
You can create a tRPC server within any edge runtime that follow the WinterCG, specifically the Minimum Common Web Platform API specification.
GitHub
astro/request-transform.ts at 2dca81bf2174cd5c27cb63cb0ae081ea2a1ac...
The all-in-one web framework designed for speed. ⭐️ Star to support our work! - astro/request-transform.ts at 2dca81bf2174cd5c27cb63cb0ae081ea2a1ac771 · withastro/astro
Nick
Nick354d ago
It might be our proxy doesn't currently support this setup, but I'm really not familiar with this tech If your conclusion is the proxy needs some changes then I'd open an issue (PRs also very welcome)
goetzrobin
goetzrobin348d ago
Thanks for getting back to me! I haven’t found a solution/fix for this as it’s really hard to debug since this only happens in said edge environment. In theory the vercel edge should be supported as mentioned in the docs: https://trpc.io/docs/server/adapters/fetch. But I haven’t had any luck so far. If I find anything I’ll open an issue/PR Can you point me to the files in the source code where that proxy you mentioned is created? Thanks already!
More Posts
How to retrieve and receive Bigint data to/from TRPC procedureNode: `v16.15.1` I'm trying to return an object which contains an `amount` property from one of my TypeError: Cannot read properties of null (reading 'useContext') when using useMutation with TRPC inI'm encountering an error in my Next.js application when trying to use the useMutation hook with TRPInitial websockets getToken() returns null: next-auth + websockets :)Hello! So the way I am trying to authenticate websockets is like this: ``` import { getToken } froCan I get the original type name, instead of the shape, with query?I'm not sure how to explain it, so, here's a screen shot:TRPCClientError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON ErrorHello folks, I'm getting an issue with my integration, I'm a newbie in tRPC and I can't work well mytrpc corsmy sveltekit app is running on https://example.com with tRPC and it's making requests to http://127.T3 app tRPC external callsCurrently i'm just making Post request and formatting my payload to ```{ "0": { "json":Next-auth session not being fetched in tRPC contextNext-auth session not being fetched in tRPC contextuseMutation not handeling arguments correctly.Hello, I have a mutation setup on the server with the input being an object containing the fields emUpdate Clerk Organization from TRPC Router (T3 Stack)Hello, if anyone got an idea on how to handle this I would highly appreciate it. I have some organiHow to not send request in specific condition in useQuery()```js const { data: artists, isLoading } = api.findArtist.useQuery({ name: search, }); ``` TRPCClientError: fetch failedI get the below error when createTRPCProxyClient runs on BE of a Next.JS app hosted on Vercel: ```T