Graphcool / graphcool-framework

Apache License 2.0
1.77k stars 130 forks source link

Many subscription events in quick succession - some events are skipped #290

Open marktani opened 6 years ago

marktani commented 6 years ago

Issue by marktani Wednesday Oct 18, 2017 at 14:25 GMT Originally opened as https://github.com/graphcool/prisma/issues/886


From @sorenbs on March 31, 2017 15:28

In the playground, start a simple subscription:

subscription{
  Issue{
    node{
      id
    }
  }
}

In a new playground tab, manually execute a mutation 12 times in a row.

mutation {
  createIssue(d: B, date: "2020", published: true, title: "lala"){
    id
    title
  }
}

Observe that only 8 events appear in the playground, even though the websocket actually receive all 12 events:

image

Copied from original issue: graphcool/console#799

marktani commented 6 years ago

Comment by mwickett Friday Oct 20, 2017 at 15:18 GMT


I think this is more than just a playground issue. I'm seeing this happening with a subscription based function in our application where a different function (operation) sets multiple records in a different collection to true. We have subscription function firing on updates to that field, and it's the incoming data stream is missing some of the records.

marktani commented 6 years ago

Comment by marktani Friday Oct 20, 2017 at 15:20 GMT


Hey @mwickett can you create a separate issue for this? If you could nail it down to a small minimal reproduction, that would be much appreciated, too! 🙂

marktani commented 6 years ago

Comment by mwickett Friday Oct 20, 2017 at 16:09 GMT


I believe I sorted out an issue with my function, so false alarm. Sorry about that!

marktani commented 6 years ago

Comment by lewisblackwood Wednesday Oct 25, 2017 at 14:42 GMT


Hey @marktani - I've observed this issue in the playground too. But I've also observed another issue with subscriptions that's causing us problems.

If I toggle a boolean field on one of my records, then the node returned in the subscription does not always contain the correct data. For example, my Hire type has a boolean field sessionsAddedToCalendar. If I register the subscription:

subscription updatedHire {
  Hire(
    filter: {
      mutation_in: [UPDATED]
    }
  ) {
    mutation
    node {
      sessionsAddedToCalendar
    }
  }
}

and toggle the field in the console, I'm often seeing playground output like this:

{
  "data": {
    "Hire": {
      "mutation": "UPDATED",
      "node": {
        "sessionsAddedToCalendar": false
      }
    }
  }
}

{
  "data": {
    "Hire": {
      "mutation": "UPDATED",
      "node": {
        "sessionsAddedToCalendar": true
      }
    }
  }
}

{
  "data": {
    "Hire": {
      "mutation": "UPDATED",
      "node": {
        "sessionsAddedToCalendar": true
      }
    }
  }
}

{
  "data": {
    "Hire": {
      "mutation": "UPDATED",
      "node": {
        "sessionsAddedToCalendar": true
      }
    }
  }
}

{
  "data": {
    "Hire": {
      "mutation": "UPDATED",
      "node": {
        "sessionsAddedToCalendar": false
      }
    }
  }
}

I don't think events have been skipped - the total number is correct. It's that the updated node doesn't reflect the correct information. It should go false -> true -> false -> true -> false.

Is there any way to fix this? We've only noticed it recently, but it's causing lots of inconsistencies on our client app 😬

marktani commented 6 years ago

Comment by marktani Friday Nov 03, 2017 at 10:20 GMT


Hey @lewisblackwood just saw this - could you please provide a reproduction for this in a new issue? 🙂