parse-community / parse-server

Parse Server for Node.js / Express
https://parseplatform.org
Apache License 2.0
20.84k stars 4.77k forks source link

Parse Server LiveQuery not updating after client reconnect #8019

Open rsurgiewicz opened 2 years ago

rsurgiewicz commented 2 years ago

Hi Folks,

Issue Description

We stumbled upon strange behavior of LiveQuery subscription. As long as the React Native app keeps open connection to Parse server all the websockets (all class subscriptions) are working just fine and the subscription update event is sent after any of the objects change. Now, once the client disconnects (app goes to background) and reconnects again (app is started) the subscription got all renewed and start working except for only one Parse class where UPDATE is never triggered ever since.

Logs

Looking into the logs, this specific class behaves as follows:

1. CLIENT NORMALLY CONNECTED (SUBSCRIPTION UPDATE running just fine)

verbose: ClassName: Effector | ObjectId: undefined
verbose: Current client number : 1
verbose: Original {“createdAt”:“2022-01-26T21:19:57.968Z”,“updatedAt”:“2022-06-01T08:57:59.389Z”,“effectorType”:{“__type”:“Pointer”,“className”:“EffectorTypes”,“objectId”:“Cmjjsh7rY5”},“alias”:“ELEWACJA”,“commandChannel”:“safeh/cmnd/tasmota_ED6E47/POWER”,“stateChannel”:“safeh/stat/tasmota_ED6E47/RESULT”,“name”:“tasmota_ED6E47”,“state”:“ON”,“stateFormula”:“POWER”,“room”:{“__type”:“Pointer”,“className”:“Room”,“objectId”:“mI7FKSenDO”},“ip”:“192.168.20.140",“description”:“1.1_elewacja_swiatlo”,“__type”:“Object”,“className”:“Effector”,“objectId”:“taS_ED6E47"} | Current {“createdAt”:“2022-01-26T21:19:57.968Z”,“updatedAt”:“2022-06-01T08:57:59.529Z”,“effectorType”:{“__type”:“Pointer”,“className”:“EffectorTypes”,“objectId”:“Cmjjsh7rY5”},“alias”:“ELEWACJA”,“commandChannel”:“safeh/cmnd/tasmota_ED6E47/POWER”,“stateChannel”:“safeh/stat/tasmota_ED6E47/RESULT”,“name”:“tasmota_ED6E47”,“state”:“OFF”,“stateFormula”:“POWER”,“room”:{“__type”:“Pointer”,“className”:“Room”,“objectId”:“mI7FKSenDO”},“ip”:“192.168.20.140",“description”:“1.1_elewacja_swiatlo”,“__type”:“Object”,“className”:“Effector”,“objectId”:“taS_ED6E47"} | Match: true, true, true, true | Query: Effector:|[]
verbose: Push Response : “{\“op\“:\“update\“,\“clientId\“:\“169eccea-af3d-4fc7-b42c-7b4fd541fafa\“,\“installationId\“:\“1168bf5b-33df-4bf7-b301-488ee0ff12cb\“,\“requestId\“:2,\“object\“:{\“createdAt\“:\“2022-01-26T21:19:57.968Z\“,\“updatedAt\“:\“2022-06-01T08:57:59.529Z\“,\“effectorType\“:{\“__type\“:\“Pointer\“,\“className\“:\“EffectorTypes\“,\“objectId\“:\“Cmjjsh7rY5\“},\“alias\“:\“ELEWACJA\“,\“commandChannel\“:\“safeh/cmnd/tasmota_ED6E47/POWER\“,\“stateChannel\“:\“safeh/stat/tasmota_ED6E47/RESULT\“,\“name\“:\“tasmota_ED6E47\“,\“state\“:\“OFF\“,\“stateFormula\“:\“POWER\“,\“room\“:{\“__type\“:\“Pointer\“,\“className\“:\“Room\“,\“objectId\“:\“mI7FKSenDO\“},\“ip\“:\“192.168.20.140\“,\“description\“:\“1.1_elewacja_swiatlo\“,\“__type\“:\“Object\“,\“className\“:\“Effector\“,\“objectId\“:\“taS_ED6E47\“},\“original\“:{\“createdAt\“:\“2022-01-26T21:19:57.968Z\“,\“updatedAt\“:\“2022-06-01T08:57:59.389Z\“,\“effectorType\“:{\“__type\“:\“Pointer\“,\“className\“:\“EffectorTypes\“,\“objectId\“:\“Cmjjsh7rY5\“},\“alias\“:\“ELEWACJA\“,\“commandChannel\“:\“safeh/cmnd/tasmota_ED6E47/POWER\“,\“stateChannel\“:\“safeh/stat/tasmota_ED6E47/RESULT\“,\“name\“:\“tasmota_ED6E47\“,\“state\“:\“ON\“,\“stateFormula\“:\“POWER\“,\“room\“:{\“__type\“:\“Pointer\“,\“className\“:\“Room\“,\“objectId\“:\“mI7FKSenDO\“},\“ip\“:\“192.168.20.140\“,\“description\“:\“1.1_elewacja_swiatlo\“,\“__type\“:\“Object\“,\“className\“:\“Effector\“,\“objectId\“:\“taS_ED6E47\“}}”
verbose: RESPONSE from [POST] /parse/batch: {
  “response”: [
    {
      “success”: {
        “updatedAt”: “2022-06-01T08:57:59.529Z”
      }
    }
  ]
} {“result”:{“response”:[{“success”:{“updatedAt”:“2022-06-01T08:57:59.529Z”}}]}}

2. CLIENT NORMALLY RECONNECTED (SUBSCRIPTION UPDATE not triggered)

verbose: ClassName: Effector | ObjectId: undefined
verbose: Current client number : 1
verbose: Original {“createdAt”:“2022-01-26T21:19:57.968Z”,“updatedAt”:“2022-06-01T09:00:11.929Z”,“effectorType”:{“__type”:“Pointer”,“className”:“EffectorTypes”,“objectId”:“Cmjjsh7rY5”},“alias”:“ELEWACJA”,“commandChannel”:“safeh/cmnd/tasmota_ED6E47/POWER”,“stateChannel”:“safeh/stat/tasmota_ED6E47/RESULT”,“name”:“tasmota_ED6E47”,“state”:“OFF”,“stateFormula”:“POWER”,“room”:{“__type”:“Pointer”,“className”:“Room”,“objectId”:“mI7FKSenDO”},“ip”:“192.168.20.140",“description”:“1.1_elewacja_swiatlo”,“__type”:“Object”,“className”:“Effector”,“objectId”:“taS_ED6E47"} | Current {“createdAt”:“2022-01-26T21:19:57.968Z”,“updatedAt”:“2022-06-01T09:00:12.111Z”,“effectorType”:{“__type”:“Pointer”,“className”:“EffectorTypes”,“objectId”:“Cmjjsh7rY5”},“alias”:“ELEWACJA”,“commandChannel”:“safeh/cmnd/tasmota_ED6E47/POWER”,“stateChannel”:“safeh/stat/tasmota_ED6E47/RESULT”,“name”:“tasmota_ED6E47”,“state”:“OFF”,“stateFormula”:“POWER”,“room”:{“__type”:“Pointer”,“className”:“Room”,“objectId”:“mI7FKSenDO”},“ip”:“192.168.20.140",“description”:“1.1_elewacja_swiatlo”,“__type”:“Object”,“className”:“Effector”,“objectId”:“taS_ED6E47"} | Match: false, false, false, false | Query: Effector:room|[{“$inQuery”:{“className”:“Room”,“where”:{“home”:{“__type”:“Pointer”,“className”:“Home”,“objectId”:“F0Z6mCkVps”}}}}]
verbose: RESPONSE from [POST] /parse/batch: {
  “response”: [
    {
      “success”: {
        “updatedAt”: “2022-06-01T09:00:12.111Z”
      }
    }
  ]
} {“result”:{“response”:[{“success”:{“updatedAt”:“2022-06-01T09:00:12.111Z”}}]}}

In case 2) the Match resulted with [Match: false, false, false, false] and the query looks to be different even though there were no changes with respect to this. Note: this only happens to this particular Class (having a Pointer to Room one). All other classes’ subscription are running just fine after CLIENT RECONNECTS

Steps to reproduce

  1. A JS Parse app with LiveQuery client up & running
  2. Temporarily disconnect connection
  3. After reconnection LiveQueryClient is no longer receiving updates from parse-server for some classes.

Actual Outcome

After reconnection LiveQueryClient is no longer receiving updates from parse-server for some classes. Match is false in logs

Expected Outcome

After reconnection LiveQueryClient should receive all updated from parse-server.

Environment

Server

Database

Client

Is it a bug? Any tips or debug steps are appreciated!

Regards

parse-github-assistant[bot] commented 2 years ago

Thanks for opening this issue!