createAsyncStoragePersistor's persistClient not respect throttleTime and not persisted final state queryClient #3331
Send to my agentDescribe the bug#
The persistClient of createAsyncStoragePersistor does not execute according to the throttleTime and not persisted final state queryClient when make many queries to refetch. To be precise, there is a problem with the function asyncThrottle.
Your minimal, reproducible example#
Steps to reproduce#
Just run the code on the TypeScript playground.
- Click 'Run' button on the left panel.
- Click 'Logs' button on the right panel.
- Check output logs.
Expected behavior#
Case1: Expect log two lines and print maximum id but got four lines and not print maximum id. Case2: Expect log two lines and print maximum id but got one line and not print maximum id.
How often does this bug happen?#
No response
Screenshots or Videos#
No response
Platform#
Only react native.
react-query version#
v4.0.0-alpha.14 and v3.34.16
TypeScript version#
No response
Additional context#
No response
@TkDodo Thank you for your prompt response! Regarding your test, simply speaking the results of the third party library are right and the best. Case 2 expects to print once or twice is acceptable, but the last time must output that maximum id, otherwise the final state may not be persisted.
would you like to do that?
Yes! I will fix this problem later.
@huanguolin to do that, I moved the log statements to after the delay:
case 1 (id: 2). timestamp: 1645607386557 case 1 (id: 4). timestamp: 1645607387561 case 2 (id: 2). timestamp: 1645607388528looking at the ids and the timestamps, this seems legit. Thank you for tackling this 🙇
TkDodo added labelsbug
huanguolin(GitHub profile, opens in a new tab) changed the title
@TkDodo I updated the bug description and then submitted the pr.
TkDodo added labelsv4
TkDodo closed this
:tada: This issue has been resolved in version 4.0.0-alpha.19 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
tannerlinsley added labelsreleased on @alpha
:tada: This issue has been resolved in version 4.0.0-beta.1 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
tannerlinsley added labelsreleased on @beta
Sign in to join this conversation.
Thanks for reporting. If you know how to fix it, I think the best thing would be to:
alphabranchwould you like to do that?
I quickly tried out the first async-throttle package I could find on npm and made a codesandbox with your tests:
btw, I'm not suggesting to add a dependency, just saying we can use this or other implementations as reference.