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

Cancel the previous request if another one has been sent. #198

Open
radekg12 opened this issue Jan 8, 2021 · 1 comment
Open

Cancel the previous request if another one has been sent. #198

radekg12 opened this issue Jan 8, 2021 · 1 comment

Comments

@radekg12
Copy link

radekg12 commented Jan 8, 2021

Please add the option to cancel the previous request, if it is in the Pending status, and in the meantime, another request has been sent (similar to switchMap in RxJS).

Problem:
Now, when I send the request, the text "Searching ..." is displayed, which is correct. However, when I enter a few more letters while I haven't received the response for my first request yet, a bug may appear. The results from the first request will be displayed while the second request will be in the Pending status and there is no information about it. "Searching ..." word is not visible on the Select element. This is especially problematic if you have to wait a long time for a response. Additionally, there may be a potential race condition of requests.

Example (race condition):
Example, when I type ABC the request with query param q=ABC, will be sent. Meanwhile, after we paused for a bit (more than the debounce time), we decide to type in another letter (the letter D) our app sends the request to the server with ABCD string. The results for string ABCD was cached so server replies very quickly. A few seconds later, however, the server finally replies with the response for the ABC string and overwriting results for string ABCD.

Diagram to illustrate the issue:
// A1: Request for ABC
// A2: Response for ABC
// B1: Request for ABCD
// B2: Response for ABCD

--A1----------A2-->
------B1--B2------>

@Nitrodist
Copy link

FYI this is called debouncing

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

No branches or pull requests

2 participants