Reducing the frequency of display for the warning "Draft is being edited in another window."

OK, I have a fix here:

https://github.com/discourse/discourse/commit/a29ae17d3a57c6cd92716b53bbab5b9a229f77e7

Thank you so much for the repro here it was spectacular and helped me isolate the issue quickly.

I feel like I had a bit of a hand-wavy answer to how we keep track of draft versions, I think it boils down to me being a bit too naive and fancy in my algorithm. That is a deadly combo. The new algorithm is far easier to explain.

  • Whenever the client saves a draft, it tells the server what “sequence number it has”

  • If the sequence number matches, server will increase the sequence number by 1 and give it back to the client (our new sequence number)

  • If the sequence number does not match, the server will tell the client there is a conflict and not save the draft

  • On page reload / load the server tell the client what the current sequence number is

My previous implementation was too fancy, it tried avoiding increasing the sequence number under lots of conditions by tracking owner of a sequence. Your test case showed how bad that is and how it can cause content loss.

This should be live on meta, let me know if you can find more edges in this system.

10 Likes