Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cache infinite loading issue with debounce [bug fix] #19

Closed
wants to merge 5 commits into from

Conversation

braden-m
Copy link

@braden-m braden-m commented Mar 4, 2019

There is currently an issue when debounceTimeout is set where some searches will appear to "load" forever (i.e. display the loading icon), but not actually perform a search.

You can test the issue yourself with the simple debounce example: https://codesandbox.io/s/5y2xq39v5k

You're not able to view the state of AsyncPaginate (I suppose since codesandbox.io is using an iframe?). However, you can repeat the bug by following these steps:

  1. On a fresh reload (i.e. without searching previously), type "option" quickly into the select box.
  2. Wait until the search results return.
  3. Clear the select box, then type in any of "o", "op", "opt", "opti", or "optio" - that is, any search term that is typed in the process of typing "option", but does not have time to actually perform the search due to debounce.

The "search" for these terms will seem to go on infinitely, and never return any results.


This is due to the optionsCache state variable on AsyncPaginate being filled with the search options as they are typed. This PR moves setting the cache until after the debounce timeout, so that queries which do not run are not cached.

@codecov
Copy link

codecov bot commented Mar 4, 2019

Codecov Report

Merging #19 into master will increase coverage by 0.51%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #19      +/-   ##
==========================================
+ Coverage    89.1%   89.62%   +0.51%     
==========================================
  Files           5        5              
  Lines         101      106       +5     
  Branches       18       18              
==========================================
+ Hits           90       95       +5     
  Misses          5        5              
  Partials        6        6
Impacted Files Coverage Δ
src/async-paginate.jsx 92.98% <100%> (+0.67%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a2063e0...46ef953. Read the comment docs.

@chrisnager
Copy link

I, too, had this issue and this PR fixes the infinite loading debouncing bug. Nice work!

@vtaits
Copy link
Owner

vtaits commented Mar 24, 2019

I fixed something like this in 0.2.9, you can check.

@vtaits vtaits closed this Apr 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants