Race conditions induced by network lag can cause incorrect number of donated lingots to appear

So this is a super minor bug but I figured I'd report it anyway.

If you click "give lingot" twice on a slow network (:(), then on some occasions the counter can jump from 0 (hidden) to 2, and then back down to 1.

My guess for the cause is that the AJAX responses for the "give lingot" requests contain a field for "new total number of lingots donated," which replaces the old value when the response is received. In the case where network lag causes the second response to be received first, the first response subsequently stomps the old value.

(I can't verify this because I didn't have the network tab open at the time of incidence, but it seems highly likely.)

Probably the simplest fix, which would require changes only to client-side code, would be to only change the field when a response newer than the last-processed response is updated. Under these semantics, the first response would be ignored entirely.

Again, this is minor because it doesn't occur frequently (I've seen it just once) and has no server-side effects.

August 24, 2015

0 σχόλια

Μάθε μια γλώσσα αφιερώνοντας μόνο 5 λεπτά τη μέρα. Δωρεάν.