You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Query with subscribed: false returns undefined due to mutation race #5346
Create an API with a query and a mutation sharing the same cache tag
Start a request for the query with subscribe: false
Start a request for the mutation
If the mutation completes right before the query, the query returns undefined, breaking its API contract (types claim that undefined is never returned)
git clone https://gist.github.com/1459bcabb66c5bb2c6c72f32f07fce3f.git rtk-query-unsubrace
cd rtk-query-unsubrace
npm install
npm start
The delay might need to be adjusted depending on the host machine. On my machine, the hardcoded delay is enough to hit the race consistently. If you can't reproduce with the hardcoded delay, use the random delay and let the script run for a while.
Setting subscribe: true and calling unsubscribe() after awaiting the query works around the bug. Calling unsubscribe() any earlier is not enough.
changed the title [-]Query with `subscribed: false` returns undefined due to mutation race[/-][+]Query with `subscribed: false` returns `undefined` due to mutation race[/+]on Nov 2, 2026
Activity
[-]Query with `subscribed: false` returns undefined due to mutation race[/-][+]Query with `subscribed: false` returns `undefined` due to mutation race[/+]emersion commentedon Nov 6, 2026
Thanks for the fix @markerikson!