useful-forks.github.io
useful-forks.github.io copied to clipboard
Allow users to manually abort
Potentially:
- When reaching 80% of the remaining Rate Limited calls
- Turn the "loading" button red and if clicked: abort
A proposed implementation was made there: https://github.com/useful-forks/useful-forks.github.io/issues/7#issuecomment-787044619
Aborting all ongoing Promises isn't as trivial as I thought. There is a partial solution, but I'm still waiting on something that fulfills the 3 constraints listed there: https://stackoverflow.com/q/67086017/9768291
what about using AbortController? See https://github.com/octokit/rest.js/blob/2c7bf0c4c1121e03dae135768f20b983f1015b78/docs/src/pages/api/03_request_formats.md
@micalevisk
Say I have 100 calls to make, and that after 70 I realize I need to stop. From what I understand, the AbortController
indeed helps with avoiding the necessity to await the 70 calls to receive a response. But would it help with making sure that the following 30 requests that were supposed to be issued would get cancelled before being executed?
I didn't used AbortController
API yet. But I guess each call could have its own abort signal, so you can invoke those controllers as you wish as long you track them properly
30 requests that were supposed to be issued would get cancelled before being executed?
Yes. You just pass the signal
to fetch
and when the call is made, it be immediately fail because the signal was already given.