T
tRPC

❓-help

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

Ssanti4/27/2023
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,
},
)
const updatedCartItems = await trpcClient.user.cart.replaceCartOnAuthLoaded.mutate(
{
anonymousCartItems,
},
{
onlyOneAtATime: true,
},
)
Nnlucas4/27/2023
React-Query should do de-duping for you no? Do you have any more details or a reproduction of the issue? If it's batching up 2 requests, one of which RQ would be cancelling, this may be a bug on our side?
Ssanti4/27/2023
No - they're both running

Looking for more? Join the community!