Is it possible to create 2 routers inside a single file?

I am having an issue in which it is impossible to me to use a class instance within 2 routers. I tried declaring the routers in a single file and then exporting them, it doesn't work. The issue I am facing is this: https://github.com/vercel/next.js/issues/49309 Any insight/help would be greatly appreciated.
GitHub
Module imported in different files re-evaluated · Issue #49309 · ve...
Verify canary release I verified that the issue exists in the latest Next.js canary release Provide environment information Operating System: Platform: linux Arch: x64 Version: #1 SMP Wed Mar 2 00:...
N
Nick333d ago
Can you share a bit more what you mean? Maybe a code example? Given that's a Next bug, if it really is that, I'm not sure we can help much here
Y
youwontstopme:)333d ago
@Nick Lucas I am trying to use a singleton class instance which is storing a hash map of eventemitter objects which I want to use for subscriptions. What happens specifically is that when I emit an event, it is emitted on an instance that has no callbacks registered. This is due to the next bug, re-evaluating an import from an external file and replacing its pointer in memory with a newly empty created instance. The way I tried to avoid this, since I want to use that class instance in 2 routers, I tried to create my 2 routers inside a single file, declare the class instance in there and move on, but didn't work. I didn't try to merge the 2 routers into 1 however, I will do that tomorrow and get back to you.
N
Nick333d ago
This definitely sounds like a weird bundling issue, or that Next is recreating your backend on each request (which may be a feature rather than a bug) Trpc itself is fine with you exporting 2 routers from the same file or having a singleton
Y
youwontstopme:)332d ago
Yeah I don't know, I implemented redis and everything is working properly.
More Posts
Use onError to change an application error into a TRPCError?I want to use the onError handler to change any instance of a custom application error into a TRPCErIncreasing Body 1mb limitHey, Im trying to build an application that allows sending of base64 encoded files to my next.js serNitro and tRPC in vercel-edgeHey there! I hope this is the right place to ask for help. I am trying to deploy an application witHow 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: ```TinferRouterOutputs not inferringCould anyone point me in the right direction to why my types aren't being inferred here? (Using T3 b