santiS
tRPC3y ago
3 replies
santi

Bug where 2 requests are fired at once. TRPC batches them. Can I cancel the 2nd via ProcedureOption?

Hey all. I have a bug where my app fires two identical requests at the same time. This happens do to some weird upstream auth listener logic. Ideally TRPC can help me mitigate this. I want to configure
ProcedureOption
such that it doesn't batch, but rather only lets the first request to go through. Is this possible?
const updatedCartItems = await trpcClient.user.cart.replaceCartOnAuthLoaded.mutate(
  {
    anonymousCartItems,
  },
  {
    onlyOneAtATime: true,
  },
)
Was this page helpful?