SplitTime / OpenSplitTime

Timed endurance event data
https://www.opensplittime.org
MIT License
27 stars 10 forks source link

Lottery | Draw Tickets sometimes doesn't work #590

Closed tbstockton closed 2 years ago

tbstockton commented 3 years ago

Clicking the Draw Tickets button doesn't appear to update the Progress bar after leaving "Draw Tickets" by clicking on the "Setup" tab and then returning to "Draw Tickets" to draw more tickets. Inconsistent hard to reproduce behavior, almost appears to be long delay.

Doesn't throw an error in the console.

moveson commented 3 years ago

I was having some similar difficulties this morning (Monday, October 11). For me, the trouble was that one of the test lotteries had more slots than it had entrants to draw, so the "Draw Ticket" button remained enabled even though there was nobody left to draw.

This wouldn't happen in a real lottery where we will have more entrants than slots, but I'd like to address it in any case. The way I'd like to address this is to ensure the "Draw Ticket" button is disabled not only if the lottery is full, but also if all entrants have been drawn.

@tbstockton Is it possible this was what you were experiencing?

tbstockton commented 3 years ago

@moveson I don't think so. I think I was seeing the 'Newbies' lottery still pulling entrants but the progress bar wasn't updating. This might have been after one of the other lotteries was over full and caused an error? I'll test some more this morning.

tbstockton commented 3 years ago

@moveson
To reproduce I did: 1 - Drew 2 Newbies 2 - Drew 15 Vets (filled it) 3 - Drew 11 Goonies (filled it) 4 - Clicked on "Setup" tab 5 - Clicked on "Draw Tickets" tab 6 - Newbies Draw Ticket wouldn't respond

Contrived I know ...

moveson commented 3 years ago

Thanks for doing this research, @tbstockton ! I'll see if I can reproduce it on my end.

moveson commented 3 years ago

I was able to reproduce this. It does not depend on the number of draws or whether a lottery is filled.

The problem seems to occur only when the user switches quickly from Draw Tickets to Setup and back again within a very short period, like under a second. My hypothesis is that when changing back to the Draw Tickets screen, the underlying JS code is attempting to subscribe to the Turbo Streams that make the page work while the JS is still busy unsubscribing from those same streams as a result of switching to the Setup view.

In any case, this is an issue with Turbo, and I've created an issue there describing this problem. See https://github.com/hotwired/turbo/issues/422

moveson commented 3 years ago

Further research shows that this can occur when switching back and forth from Setup to Draw Tickets even when it's not done very quickly. And once it's a problem, it seems to remain a problem and sometimes gets worse the more switching is done.

A page refresh seems to fix the problem every time. I'm going to try disabling the Turbo Drive feature when switching between these two pages. That will make for slightly less snappy feel when switching, but it may solve this problem.

moveson commented 3 years ago

595 appears to have fixed the problem.

@tbstockton Please let me know if you are able to reproduce the problem with this fix in place.

moveson commented 3 years ago

We are not the only ones that were experiencing this problem. It was fixed in Rails via a PR that was merged just a few weeks ago: https://github.com/rails/rails/pull/41581

We'll wait for the next Rails version release and then we can upgrade and revisit this issue.