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

Being able to pause requests #92

Open
vixez opened this issue Oct 19, 2021 · 12 comments
Open

Being able to pause requests #92

vixez opened this issue Oct 19, 2021 · 12 comments
Assignees
Labels
feature_request help wanted Extra attention is needed

Comments

@vixez
Copy link
Contributor

vixez commented Oct 19, 2021

Is your feature request related to a problem? Please describe.
The app I'm building can fire multiple requests at once.
When one of the requests gets a 401 for an expired token, it updates the token in a RetryPolicy.
During this update, all other requests should be paused as a new token is being retrieved.

Describe the solution you'd like
Be able to pause requests in the queue, and resume them. For example pausing the queue when a new token is being retrieved.
After the token is updated, all requests in the queue should have their interceptRequest method called, so the request can be updated with the new token (if an old token is in the request).

An alternative would be that everything runs in a sequence, no simultaneous requests.

  • Request 1: Added to queue
  • Request 1: interceptRequest
  • Request 2: Added to queue
  • Request 1: 401 => RetryPolicy + pause all requests in the queue
  • Request 1: Asynchronously finish shouldAttemptRetryOnResponse (token in storage updated)
  • Request 1: Retry so > interceptRequest
  • Request 1: finish successfully
  • Request 2: interceptRequest
  • Request 2: finish successfully
  • ...
@vixez
Copy link
Contributor Author

vixez commented Oct 19, 2021

I have created a PR for how I currently solved this issue.

@CodingAleCR
Copy link
Owner

Really interesting FR (Feature Request). Is this request based on the need for having multiple requests but refresh token only once for all subsequent requests?

@CodingAleCR
Copy link
Owner

This could be interesting as well if the "pausing" was performed when the retry policy is triggered instead of always as well, in any case, how would you feel about this?

@vixez
Copy link
Contributor Author

vixez commented Oct 25, 2021

Hey,
Yes, we use the client to talk to our own backend. So when one of the requests returns a 401 all future requests should wait until the token is refreshed.
If the token fails to refresh it could be nice to cancel further requests, since they will fail anyway without a token.

Maybe requests could be 'grouped' by a GUID, or adding tags to requests. With some way to cancel requests that belong to a certain group/tag.
This would be convenient to cancel pending requests when a user is logged out due to an expired token, and cancel pending requests that user authentication. Se that group or tag would be cancelled then.

@vixez
Copy link
Contributor Author

vixez commented Oct 28, 2021

@CodingAleCR
I have created a PR with how I implemented it in my app (both the limiting and pausing of requests), albeit a bit more abstract.

@stale
Copy link

stale bot commented Dec 27, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Dec 27, 2021
@stale stale bot closed this as completed Jan 6, 2022
@CodingAleCR CodingAleCR reopened this Jan 6, 2022
@stale stale bot removed the wontfix This will not be worked on label Jan 6, 2022
@stale
Copy link

stale bot commented Mar 9, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Mar 9, 2022
@stale stale bot closed this as completed Mar 16, 2022
@shinayser
Copy link

Hey @CodingAleCR please take a look on this issue. The bot seems not not like it and keeps closing xD

@brxxxx
Copy link

brxxxx commented Feb 11, 2023

Any developments on this feature?

@CodingAleCR CodingAleCR reopened this Feb 11, 2023
@stale stale bot removed the wontfix This will not be worked on label Feb 11, 2023
@CodingAleCR
Copy link
Owner

There's a PR outdated that deals with pooling requests and working on pauses. But other than that there's no current development at the moment.

Feel free to drop a PR with an implementation if that's something you think could help 😉👌🏼

Thank you both for bringing this up as well!

@CodingAleCR CodingAleCR added the help wanted Extra attention is needed label Feb 11, 2023
@stale
Copy link

stale bot commented May 4, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label May 4, 2023
@stale stale bot closed this as completed May 21, 2023
@CodingAleCR CodingAleCR reopened this May 21, 2023
@stale stale bot removed the wontfix This will not be worked on label May 21, 2023
@stale
Copy link

stale bot commented Aug 10, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Aug 10, 2023
@stale stale bot closed this as completed Sep 17, 2023
@CodingAleCR CodingAleCR reopened this Sep 18, 2023
@stale stale bot removed the wontfix This will not be worked on label Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature_request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants