santi
santi15mo ago

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,
},
)
const updatedCartItems = await trpcClient.user.cart.replaceCartOnAuthLoaded.mutate(
{
anonymousCartItems,
},
{
onlyOneAtATime: true,
},
)
2 Replies
Nick
Nick15mo ago
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?
santi
santi15mo ago
No - they're both running