use-http icon indicating copy to clipboard operation
use-http copied to clipboard

Cannot abort delayed retries

Open veloware opened this issue 3 years ago • 0 comments

Describe the bug When using retries, when the fetch is in the delay stage, i.e. delayed between retries, calling the abort function from the useFetch() hook has no effect.

⚠️ Make a Codesandbox ⚠️ Please do this to easily reproduce the bug.

To Reproduce Steps to reproduce the behavior:

  • attach the abort() function to a button
  • make a fetch call that will cause a retry, with a reasonable delay for testing, say 5 secs.
  • after the first request has fullfilled and the fetch hook will delay for 5 secs before making the next request
  • during the delay, before the next request happens, click the button to call abort()
  • nothing happens, and the next request will eventually happen after the defined 5 secs.
  • click the button whilst the request is still in flight
  • it is finally aborted

Expected behavior If delays are possible, it shouldn't matter when the abort is clicked, the subsequent requests should be aborted, not just an in flight request.

veloware avatar Jun 20 '22 15:06 veloware