Subscriptions seem to have a caching issue #510
Labels
subscription-link
Related to AppSync Subscription Link issues
to-be-reproduced
We need to reproduce this issue
Milestone
Do you want to request a feature or report a bug?
bug
What is the current behavior?
We subscribe to a query using the
subscribeToMore
function of apollo.We then use the
updateQuery: (previousResult, ...args) => { ... }
function to update the query when new subscription data comes in.Our items always have an id and a version
{ id: string, _v: number, ... }
. Merging is done by going through the query items and update the entry with the fittingid
if the entry coming from the subscription has a higher version or inserting if the entry does not exist yet.What we noticed is that if we are getting subscriptions e.g.
where the version is in correct order, everything is fine. If we get
ordering incorrect, but with some time difference everything is fine too,
Bob
is displayed.But, if we are getting subscriptions in rappid succession in wrong ordering
Bob is displayed. When debugging the
updateQuery: (previousResult, ...args) => {
function we saw that even though{ id: '1', _v: 4, name: 'Bob' }
is just coming in, it seems to already be part of thepreviousResult
entry. Which is weird as it just came back from the subscription.Is there a possibility that there is some caching going on inside the AwsAppsync subscription client ? Or are those subscription updates handled asyncronously ?
The reason why we are coming to this conclusion is that if we change the
dataId
to include the version, this issue dissappears:What is the expected behavior?
Subscriptions coming in in rappid succession should be handled in syncronously.
Which versions and which environment (browser, react-native, nodejs) / OS are affected by this issue? Did this work in previous versions?
We were able to reproduce this in Chrome and Firefox
The text was updated successfully, but these errors were encountered: