MonoliYoda / evve_dashboard_dev

0 stars 2 forks source link

Race condition causing creation and removal of structure timers to fail #8

Closed SoCariEVE closed 4 years ago

SoCariEVE commented 4 years ago

Under normal operation, adding and removing structure timers can often fail. However, interrupting execution of the postNewTimer() and postDelTimer() functions with a debugger allows these operations to succeed.

There appears to be a race condition here.

SoCariEVE commented 4 years ago

I've actually already solved this before submitting the issue. I'm just documenting here because it's a useful process to help me learn. The jQuery ajax() function can take a settings object with a complete key:

https://api.jquery.com/Jquery.ajax/#jQuery-ajax-settings

Its value is a function which is executed only when the AJAX query completes. Moving document.location.reload() into this function seems to fix the race condition.

MonoliYoda commented 4 years ago

Nice. Thank you very much. Is this fix commited to the dev branch?