-
Notifications
You must be signed in to change notification settings - Fork 462
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
fix(graphcache): Prevent offlineExchange from issuing duplicate operations #3200
Conversation
I forgot to write here too that this still doesn't fix #3093 as is unfortunately. See #3093 (comment). |
@frederikhors: Should be fixed now. In short, coming back to this, I think it's best to just force the flushed operations to always use |
Ok. I tried. It works, but. The cached data is used on the cold load now. ✅ The are no multiple requests for the same call. ✅ But I realized that now on cold start on page reload there is no longer the loading indicator I had before, using the following custom exchange: const pendingRequestsExchange: Exchange = ({ forward }) => {
function before(op: Operation) {
if (op.kind === 'subscription') return;
if (op.kind && op.kind === 'teardown') {
console.log('call deletePendingRequest');
deletePendingRequest(op.key);
} else {
console.log('call addPendingRequest');
addPendingRequest(op.key);
}
}
function after(op: OperationResult) {
deletePendingRequest(op.operation.key);
}
return (ops$) => {
const forward$ = pipe(ops$, tap(before));
return pipe(forward(forward$), tap(after));
};
}; This is happening because it now calls immediately This is not what I expect during the cold start with the cache data already there. |
Added reproduction for the latest issue here: #3093 (comment). |
@frederikhors: I can't debug your exchange for you, but you will have to adjust your Edit: For now, I'll consider it solves, since I'm assuming your |
Thank you for the answer, @kitten.
The thing is the Is firstly called the {"key": 6065549779, "kind": "query", ...} and then IMMEDIATELY the {"key": 6065549779, "kind": "teardown", ...} Can you help me understand if this is a "new behavior" or is my exchange? I do not understand why the This only happens at the reload of the page, on what I call "cold start". This new behavior is reproduced here: https://codesandbox.io/p/sandbox/issue-urql-6-duplicated-requests-forked-0ybcue. You can see the |
Follow-up to #3199
Resolves #3093
Set of changes
failedQueue
inofflineExchange
'sflushQueue