Automattic / simplenote-electron

Simplenote for Web, Windows, and Linux
https://app.simplenote.com
GNU General Public License v2.0
4.82k stars 558 forks source link

Synchronization issues with Tags #2454

Open eshurakov opened 4 years ago

eshurakov commented 4 years ago

Renaming a tag from iOS results in a blank tag showing inside a note in the web app. Trying to do something with this tag later in the web app results in tags duplication and synchronization issues.

Please take a look at the following video: Tags.mov.zip

Expected

Tags look and order is the same on all devices.

Observed

Reproduced

  1. Open the web app and iOS app
  2. On the web: add tags t1, t2, t3, t4 to the note
  3. See that the order of tags is different
  4. iOS: Rename t2 to t2-1
  5. Web: Tag t2 in the note becomes empty
  6. Web: Rename tag t2-1 to t2-1-1
  7. Web: There are now 2 tags t2-1-1

Where did you see the bug

codebykat commented 3 years ago

@belcherj was this fixed by https://github.com/Automattic/simplenote-electron/pull/2455 or is that a separate issue?

belcherj commented 3 years ago

This is still an issue. We have different encoding on different platforms and when the encoding is different we run into issues.

belcherj commented 3 years ago
Screen Shot 2020-11-24 at 2 17 09 PM

This is because ios hashes differently than Android and Web

reginabally commented 3 years ago

There's a user report in 3642690-zen with a video recording.

sandymcfadden commented 3 years ago

I ran into something similar today in two different scenarios where it ended up with a blank tag on a note and the tag not showing in the tag list.

Scenario 1

Scenario 2

https://user-images.githubusercontent.com/1326294/106289665-edea5e00-621f-11eb-8ece-077eebf31d93.mov

fluiddot commented 3 years ago

I bumped into this issue too while I was working in adding the tags to the history screen. In my case, I managed to reproduce the Scenario 1 from the previous comment.

As far as I investigated, this problem could be related to the flow when a remove operation is sent while having multiple clients connected to the web socket.

In the following logs, you can see the messages I captured from the web socket connections of both clients when deleting the tag tag-6:

Web client messages

Channel 1 - Tag bucket

Message sent:

{
    "o": "-",
    "id": "tag-6",
    "ccid": "<MESSAGE_CID_1>"
}

Message received:

[
    {
        "clientid": "<CLIENT_ID_WEB>",
        "id": "tag-6",
        "o": "-",
        "ev": 2,
        "cv": "<CV_1>",
        "ccids": ["<MESSAGE_CID_1>"]
    }
]

Electron client messages

Channel 1 - Tag bucket

Message received:

[
    {
        "clientid": "<CLIENT_ID_WEB>", 
        "id": "tag-6", 
        "o": "-", 
        "ev": 2, 
        "cv": "<CV_1>", 
        "ccids": ["<MESSAGE_CID_1>"]
    }
]

Message sent: [the tag was already removed so probably we shouldn't send this message]

{
    "o":"-",
    "id":"tag-6",
    "ccid":"<MESSAGE_CID_2>"
}

Message received: [Simperium responds with a 404 because the tag was already removed]

[
    {
        "ccids": ["<MESSAGE_CID_2>"], 
        "id": "tag-6", 
        "clientid": "<CLIENT_ID_ELECTRON>", 
        "error": 404
    }
]

As you can see, when the remove operation is received in the Electron client, it tries to send another message with a remove operation for the same tag and receives an error because it was already removed.

I haven't checked further but my impression is that the error message is not handled properly because I noticed that the message is not removed from the channel's local queue after this. Most likely this leads to blocking any message for that tag because it keeps waiting for the previous message to be sent. So when the same tag is created in the Electron client, the update message is not being sent to Simperium. However the client sends the note update message that includes the tag, producing on the Web client the error mentioned in this issue about having an empty tag.

Screen Shot 2020-11-24 at 2 17 09 PM