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
While I was working on a custom exchange I think I have found something wrong with how the default cache exchange forward requests down to the other exchanges downstream.
I have created a codesandbox to show you the problem.
Basically I have created an exchange that deduplicates queries by cancelling the old request and forwarding the new one (switchMapExchange).
In the example attached, I issue a couple of query at the same point in time.
You'll see that even though I forward teardown actions to cancel the first request of the two, no request is effectively cancelled and unexpectedly both are completed.
Trying to solve the problem, I'm quite convinced that it derives from how the default cacheExchange handle the forward action.
It basically creates different forwarding stream for new and skipped ops and merge those streams afterwards
This approach solved my problem forwarding correctly teardown actions to default fetchExchange and cancelling request when needed.
Please let me know what you think
The text was updated successfully, but these errors were encountered:
That seems absolutely right 👍 forward should also not be called twice. It's possible, but obviously leads to subtle bugs, since it spreads out some of the code.
I can put a fix in as soon as I find the time 🙌 Thank you so much for reporting this! I appreciate that this must have been hard to hunt down!
We should likely implement a test suite that can be run on all exchanges individually to test their compliance. Maybe even add a warning if forward is called multiple times as this will often not be intentional 🤔
Hi,
While I was working on a custom exchange I think I have found something wrong with how the default cache exchange forward requests down to the other exchanges downstream.
I have created a codesandbox to show you the problem.
Basically I have created an exchange that deduplicates queries by cancelling the old request and forwarding the new one (switchMapExchange).
In the example attached, I issue a couple of query at the same point in time.
You'll see that even though I forward teardown actions to cancel the first request of the two, no request is effectively cancelled and unexpectedly both are completed.
Trying to solve the problem, I'm quite convinced that it derives from how the default cacheExchange handle the forward action.
It basically creates different forwarding stream for new and skipped ops and merge those streams afterwards
In the codesandbox linked above I have included also a slightly modified cache exchange, in which forwarded operation streams are handled differently
This approach solved my problem forwarding correctly teardown actions to default fetchExchange and cancelling request when needed.
Please let me know what you think
The text was updated successfully, but these errors were encountered: