readwiseio / obsidian-readwise

Official Readwise plugin for Obsidian
GNU General Public License v3.0
262 stars 24 forks source link

Bug: Latest Sync happened on different device #17

Open arthursoares opened 2 years ago

arthursoares commented 2 years ago

I'm running the latest version of the plugin & obsidian. I had problems where my Sync would freeze, so I uninstalled and reinstalled the plugin. Went to the website again to generate the token, and when I proceed to sync, I get this message:

"Latest sync happened on different device".

This is all I get on the console.

started sync
(unknown) Readwise Official plugin: setting interval to  0 milliseconds
(unknown) Readwise Official plugin: didn't get token data, retrying (attempt 1)
(unknown) Readwise Official plugin: setting interval to  43200000 milliseconds
2(unknown) started sync

My account is connected with an Amazon account, which the e-mail is amazon@arthursoares.com

nickmilo commented 2 years ago

I'm also having a related issue where syncing isn't working and pulls up this message in the status bar: "readwise: latest sync happened on different device..."

I've done several uninstalls, resyncs, and quit & restarts. Not sure how to troubleshoot from here

TristanH commented 2 years ago

Hey @arthursoares @nickmilo we're going to look into this ASAP for you! Will keep you posted.

tadeoos commented 2 years ago

@arthursoares @nickmilo

This notification does not in itself indicates an error.

When you use the plugin on two different devices with sync on, we need to avoid duplication of content.

Here's a potential scenario that leads to content duplication:

  1. I got highlights from a new book in Readwise.
  2. I start the sync on device A and get the note for this book in my vault.
  3. The obsidian sync runs and now I have the note also on my other device (B)
  4. The sync is triggered on device B and it fetches the same book export and appends it to the note, causing the contents of the note to be duplicated.

Each plugin instance stores in its data the id of the last sync performed, but this information can't be robustly passed around plugins on different devices. This is why in step 4 the plugin will try to initiate sync even though it already happened on a different device.

The actual mechanism we have in place in order to avoid duplicates happens during request processing on our server — if no new highlights were added since the last export was created (here we are aware of all of the exports) the meaningful status code of the response will indicate the situation that a client is requesting an export unnecessarily.

This is for the context :)

To know if it's actually broken, or just a confusing message on our part, can you let me know if there are any missing highlights in your obsidian vault when you get this message, and can you confirm that Obsidian sync happened between your devices?

I think what could potentially happen here is that you are seeing the notification before the sync between devices happened. Maybe I'm missing something and your case is not covered by my thinking here... Please let me know if it is so!

Also: how is it working for you now? I looked into our database and I saw some exports successfully generated after you posted here, so I'm assuming you're not currently blocked by this...

gemglobalventures commented 2 years ago

I'm seeing the same behaviour. Is there a way to reset the devices as I had multiple vaults but now looking to centralise on one vault on one machine but I can't get it to sync