tRPC

T

tRPC

Move Fast & Break Nothing. End-to-end typesafe APIs made easy.

Join

[TRPCClientError: opts.signal?.throwIfAborted is not a function (it is undefined)]

It's a react native app trpc v11 which works until I deleted node_modules, ran yarn install and started getting this error.

failed to parse json

calling the trpc query fails because of failed to parse JSON. this is what im calling internalApi.user.getUserById.query(); ive trying logging the incoming call in the server but the request doesnt even seem to reach the server...
Solution:
next auth was filtering the endpoint
No description

default TRPCError, try/catch & dealing with DatabaseErrors

Hi there! I'm quite new to tRPC and was hoping that someone could help me out with some general questions related to errors and errorhandling. Thanks in advance! ...

Express.JS and tRPC

guys kindly what are the differences between tRPC and express, I think they do the same work, isn't?

performance profiling tool for Trpc

I used to develop in django and there used to be cprofile or gprof2dot to profile apis, is there a similar tool for trpc?

TRPCClientError: Unable to transform response from server

I'm having a problem with tRPC Client, I'm using TurboRepo, I created the API with Fastify, TypeScript and tRPC for the backend. For the frontend, I'm using Next.JS, TypeScript and tRPC. It works, the cookies are being set, but it is always returning this error: "TRPCClientError: Unable to transform response from server".

How to improve typescript performance?

The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.ts(7056) šŸ˜¢ šŸ˜¢
tRPC has long been my favorite tool to use. However, as time has passed, my application has grown slightly bigger, and now I cannot see how it will be possible for me to continue using it... I need a way for tRPC to be scalable, to allow for the creation of hundreds of endpoints and not have to constantly worry about my editor performance. But... it's getting increasingly hard to do this. So much so that I am considering moving off it to something more scalable....
No description

websocket testing

anyone know how to test trpc websockets using something like Insomina or Postman? What url etc.

Cron job with tRPC

can I make a cron job using tRPC? I would like a tRPC endpoint to be called periodically by the same Next.js application that also hosts the tRPC api, meaning I cannot use an external service to make the request to the app. Is this possible somehow? In plain typescript, this would be something like a setInterval function that would call the server side function caller every n seconds.

UseQuery iterator not working for me

I am on tRPC v11. Using the example provided in the documentation under "streaming responses using async generators" (re: https://trpc.io/docs/client/react/useQuery) I get the following error in the client:
Cannot use stream-like response in non-streaming request - use httpBatchStreamLink
Cannot use stream-like response in non-streaming request - use httpBatchStreamLink
...

Endpoints lose Input and Output Types on tRPC Client

Environment: Node with Bun package manager What's wrong: The problem I am facing is that on the trpc client I am able to type safely access the routes, however the type annotation of the output and input gets lost. What I have: https://github.com/trpc/trpc/discussions/5881 left here all the relevant information on my pov...

Where put transformer on custom link? (upgrading to V11 with T3-Setup)

In the Screenshot are the changes I made to the TRPC-Server client. Question: Where do i put the transformer on a custom link? Question2: The callTRPCProcedure-function now gives a type error: Unsafe return of an any typed value....
No description

client server counication with webSockets

Hi, I would like to be able to send data via ws api from my frontend. Still, I don't seem to be able to send any data from the frontend to the trpc backend, I tried to do it in a way that I make mutation and I open ws connection in this procedure. Still, it reconnects me on every request and I need this connection to stay open and just send the data, is there a way to send data from trpc client - frontend to the subscription precedure? On the client, apart from onData there are only onComplete, onError, onSarted, and onStopped. ws API offers ws.send() and it seems that I can only receive data from the server, is trpc client lacking this functionality or am i missing something? Many Thanks...

How do you call a router procedure from another router procedure?

.query(async ({ ctx, input }) => {
const wikiQuery = await routerFromAnotherFile.queryWikiTable(input);
.query(async ({ ctx, input }) => {
const wikiQuery = await routerFromAnotherFile.queryWikiTable(input);
...

Cannot figure out the correct type

I am trying to use tRPC outside of React. I use it in React, but I need a separate way to use it. I found out about trpc.useUtils().client, which is perfect. But I want to make it a global object for CSR components. I cannot figure out the right type to include in to the declaration. Thank you...
Solution:
export const api = createTRPCClient<AppRouter>({ ... })

Trying to get the return type of a procedure.

Using TRPC v11. I am failing to return the type. I get the error Type alias 'ProtectedProcedureType' circularly references itself. Any ideas?...

Having great difficulty using Streaming

I wanted to use the stream api with tRPC to handle a response with alot of return values and I looked at the docs for this https://trpc.io/docs/client/react/useQuery#streaming, and when trying to use the example TypeScript gives me the error: Property 'map' does not exist on type 'AsyncGenerator<number, void, unknown>'. and my JavaScript console gives me this error as well, TypeError: _myQuery_data.map is not a function. I am using the T3 Stack with tRPC running Bun 1.1.3 with Next.js v14.2.4...
Solution:
Uhh, I think bun update did the trick, since I didn't change anything and everything worked. When people say if it ain't broke, don't fix it, this is what they mean.

Unable to abort Suspense queries

I am using trpc@11 with react-query@5. I was under the impression that as long as abortOnUnmount is true, all queries that haven't completed yet will be cancelled. Is there anything I am missing? Provider ```tsx export const TrpcReactProvider = ({ children }: { children: React.ReactNode }) => {...

Authorization and Authentication while using unstable_httpSubscriptionLink

I'm wondering what best practices are for specifying headers like bearer tokens when using httpSubscriptionLink. Currently, it looks like the API doesn't support this....