-
-
Notifications
You must be signed in to change notification settings - Fork 443
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
(retry) - Allow retryIf to avoid retrying subscriptions on non-network error #1116
Comments
Hm, I believe it may depend strongly on the transport layer. By default the Typically a subscription will only throw this once the entire observable is broken, so if it errors out: https://github.com/FormidableLabs/urql/blob/4b01dc1165c8f734175398ea4edf45139d0ba2d0/packages/core/src/exchanges/subscription.ts#L84 So far I believe that's the correct behaviour. In your example I'm noticing however that you've set this to always be I think it's a matter of perspective on whether the However we could expose the entire operation on |
hmm, i wasn't able to write a short reply, so i made a list :-)
|
It still comes back to the original problem here. If you do Most GraphQL Errors come from the schema directly and are predictable and repeatable because they're thrown by the API explicitly, e.g. for authentication or another reason.
It's not expected to. If anything, that would probably a network error, but subscriptions don't really differentiate between a start and end for most transport protocols.
I'd argue the default is most correct here which only reacts to network errors, and even for queries retrying on everything is unfortunately also not quite safe for queries 😅
Nothings changed to subscriptions in a long time, including these versions. It's probably worth mentioning though that it's up to So I think, still, in summary, the API addition makes sense, but I still want to caution you here, because I believe all exchanges here are behaving correctly, so the edge case basically comes down to your implementation of |
thanks for the fast response here. i will re-think the retry-handling in my code to make it better. |
Published in |
i use both retry-exchange and subscriptions. if there is an error on the server, while generating a subscription-event, then the error correctly arrives to the client, retry-middleware does a retry, and from this point on,
useSubscription
will be triggered multiple times for the same event.urql version & exchanges:
urql=1.10.2 or 1.10.3
retry-exchange=0.1.10
Steps to reproduce
i created a codesandbox-example, this is the server:
https://codesandbox.io/s/urql-sub-retry-problem-server-6rrhd (nothing special here)
this is the client:
https://codesandbox.io/s/urql-sub-retry-problem-client-h8ie7
open the client, open the url with the running example, and open devtools, watch the console-output. (do not leave this running too long, or the tab might become unresponsive)
the server is set up so that it generates a new event every second, and has a 60% chance to
throw
while doing so.while you get no errors, the new events arrive correctly, but after the first error happens, retry happens, and things get to arrive duplicated. when more errors happen, it becomes even more duplicated.
if you change the codesandbox example, to switch
urql
to version1.10.1
, then it is suddenly fixed. it now works correctly.unfortunately, in my local codebase reverting to
urql=1.10.1
does not fix the problem. i do not understand why, maybe a combination of package-versions?Expected behavior
actually i am not even sure what exactly should happen, a subscription-event cannot really be retried. but duplicate events should not happen.
Actual behavior
i am getting duplicate events.
The text was updated successfully, but these errors were encountered: