Skip to content

Retrying failed requests with Flow.retry #1986

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

Closed
ifeomaro opened this issue Feb 11, 2020 · 2 comments · Fixed by #1997
Closed

Retrying failed requests with Flow.retry #1986

ifeomaro opened this issue Feb 11, 2020 · 2 comments · Fixed by #1997
Assignees

Comments

@ifeomaro
Copy link

ifeomaro commented Feb 11, 2020

Hello 👋 .

I have a request that needs to be retried when there's a failure:

apolloClient
    .query(MyAwesomeQuery())
    .toFlow()
    .retry(retries = MAX_RETRY_COUNT)
    .flowOn(dispatcher)

However, retrying the request results in an IllegalStateException "Already Executed" error from Retrofit which is expected since a Retrofit call can only be executed once. When I add clone() to the request, I still get the same error.

apolloClient
    .query(MyAwesomeQuery())
    .clone()
    .toFlow()
    .retry(retries = MAX_RETRY_COUNT)
    .flowOn(dispatcher)

What is the expected behavior for ApolloQueryCall.clone()?

I'm not able to add a label, but this is a question.

@sav007
Copy link
Contributor

sav007 commented Feb 12, 2020

Looks like we need to do ApolloCall.clone inside the flow creation:

fun <T> ApolloCall<T>.toFlow(capacity: Int = Channel.UNLIMITED) = flow {
...
clone().enqueue(ChannelCallback(channel = channel))

@sav007
Copy link
Contributor

sav007 commented Feb 13, 2020

I will take this issue.

sav007 added a commit to sav007/apollo-android that referenced this issue Feb 14, 2020
sav007 added a commit to sav007/apollo-android that referenced this issue Feb 14, 2020
tasomaniac pushed a commit that referenced this issue Feb 14, 2020
* Make flow extensions be retryable

Closes #1986

* Fix issue with converting `ApolloCall` to flow, when chanel is not close when flow is canceled
Fix KDocs formatting

* Fix #1808

* Deprecate `toChannel`
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 a pull request may close this issue.

3 participants