You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a running query task is cancelled, Apollo currently throws ApolloClient.Error.noResults instead of propagating CancellationError. This happens when the query has not yet produced any results—for example when using .networkOnly or when the cache is empty.
The error description for ApolloClient.Error.noResults is:
The operation completed without returning any results. This can occur if the network returns a success response with no body content.
If using a `RequestChainNetworkTransport`, this can also occur if an interceptor fails to pass on the emitted results.
I’ve attached a simple project and a video that demonstrates the issue where cancellation consistently results in .noResults.
If at least one result is emitted before cancellation, Apollo would correctly propagate CancellationError.
If zero results are emitted before cancellation, the loop exits and falls through to the guard, which throws .noResults, effectively squashing the cancellation error.
Question
Is this behaviour intended? Would it make sense for Apollo to also check Task.isCancelled before throwing .noResults, so cancellations result in CancellationError?
This would allow us to reliably distinguish between (since the noResults error description doesn't match the behaviour):
Question
Summary
When a running query task is cancelled, Apollo currently throws
ApolloClient.Error.noResultsinstead of propagatingCancellationError. This happens when the query has not yet produced any results—for example when using.networkOnlyor when the cache is empty.The error description for ApolloClient.Error.noResults is:
I’ve attached a simple project and a video that demonstrates the issue where cancellation consistently results in
.noResults.output.mp4
ApolloCancellationBug.zip
Environment
Where the behaviour occurs
In RequestChain, within:
The relevant code path is:
Observed behaviour
CancellationError..noResults, effectively squashing the cancellation error.Question
Is this behaviour intended? Would it make sense for Apollo to also check
Task.isCancelledbefore throwing.noResults, so cancellations result inCancellationError?This would allow us to reliably distinguish between (since the
noResultserror description doesn't match the behaviour):Thanks!