Setting requestPolicy:cache-and-network in the client causes data to be intermittently lost #1071
-
When I set requestPolicy to cache-and-network in the Here is a log when the request policy is set globally:
And when I set it in the
(note that fetching is never set In the urql-devtools I see that the query is torn down and then reexecuted. What condition causes this teardown? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 17 replies
-
That’s pretty odd! Do you have some details on your setup? Is the only difference where you’re passing |
Beta Was this translation helpful? Give feedback.
-
So based on the template here: https://codesandbox.io/s/peaceful-grothendieck-eoofk I can see that you have two identical That means when you have two identical hooks with identical inputs, then some results and requests will be deduplicated. In this case that may mean that you have a mount with both hooks, two initial requests, then you have both also start to render. When we render we re-subscribe to results for the operation. But technically, internally there's only one operation if you have two identical inputs mounted at the same time. That means that both hooks start to share results and this leads to some side-effects. Suddenly this means that you become subject to React's timing. While both hooks get the same results, one may have expected to not get them at that specific time. This is specifically because mounting (first render) and effects in React are separate. You can basically get this to work as a workaround by removing Instead, it's unexpected to ever have the same operation mounted twice in React. |
Beta Was this translation helpful? Give feedback.
-
Posting here again; we did eventually find a solution for this edge-case that will also improve behaviour in certain other cases 🎉 I've created a new sandbox to include the new pre-release packages to demonstrate this: https://codesandbox.io/s/modest-heyrovsky-7bnq7 You can expect this to be shipped soon 👍 |
Beta Was this translation helpful? Give feedback.
Posting here again; we did eventually find a solution for this edge-case that will also improve behaviour in certain other cases 🎉 I've created a new sandbox to include the new pre-release packages to demonstrate this: https://codesandbox.io/s/modest-heyrovsky-7bnq7
You can expect this to be shipped soon 👍