apollographql / apollo-link

:link: Interface for fetching and modifying control flow of GraphQL requests
https://www.apollographql.com/docs/link/
MIT License
1.44k stars 344 forks source link

Apollo--link-retry slowing down device #1117

Open creambyemute opened 5 years ago

creambyemute commented 5 years ago

Hey there,

I'm using apollo-link-retry with Infinity max attempts (no other configuration) in a react-native project to achieve persisted offline mutations (so that optimisticResponse is not reverted by a link-error)

Expected Behavior If I enable apollo-link-retry && the device isOffline: I expected that the device is not getting slower & slower or that an app restart fixes it (not device restart)

Actual Behavior If I enable apollo-link-retry && the device isOffline: The device is getting slower and slower (it's not getting worse anymore at some point) and the device has to be restarted in order to achieve the normal performance again.

Shutting down the app and restarting it doesn't change anything, only a device restart gets it back to normal.

Suspicion The timeouts used to retry a request again may be the problem. When debugging and looking at the chrome dev console I see a warning about it from React-Native.

*A simple reproduction** I don't have one yet, wilp try to create a sample repo.

k90armstrong commented 5 years ago

I think I am seeing the same issue, @creambyemute did you ever figure out a solution?

creambyemute commented 5 years ago

@k90armstrong Try checking the retryQueue. In my case, it got filled with duplicate requests, so the queue got longer and longer. Fixed that by not adding duplicate requests and dropping (not retrying) requests that are in the retryQueue but not in the pendingMutations queue anymore.