Likes are getting undone by the auto-update


(Kane York) #1

After you like a post, the server sends a message to everyone viewing the topic to refresh the post. This includes you, and sometimes when you reload the post, your like isn’t there. So the like button reappears. If you click the like button again, the server rejects it (you already liked the post), so the like button reappears because the request failed.

Reloading the page gets to the correct state.


(Jeff Atwood) #2

Yes @sam is aware of this bug, but cannot repro it, pretty sure it is timing related since we are both in CA and close to the servers at he.net whereas Sam is in the land of


(Sam Saffron) #3

HA

I had this reproed on Friday, was just a fairly involved series of changes, cause there were a series of bugs that needed fixing.

Anyways, should be fixed now:

https://github.com/discourse/discourse/commit/9aec32688b3dc3bca1abc1bb65e4d73de79c5acf

In case anyone is wondering after_save in Rails actually means sort of after save sometimes. When transactions get involved (which they do) after_save can be called before data is committed to the DB. If all the stars align

  • Change is made to the model
  • After save tells message bus that something changed
  • Client figures out something changed
  • Client ask server for the change on the post
  • Client gets an old copy of post actions
  • Data is committed to DB

End result disasta pasta.

I patched 2 areas where this happened (site settings and post actions) but need to review more places where MessageBus.publish is called. .


(Sam Saffron) #4

This topic was automatically closed after 24 hours. New replies are no longer allowed.