openHPI / codeocean

CodeOcean is an automated assessment tool for web-based coding exercises
BSD 3-Clause "New" or "Revised" License
64 stars 27 forks source link

Prevent simultaneous code execution requests in JavaScript #2599

Open MrSerth opened 22 hours ago

MrSerth commented 22 hours ago

With these changes, we prevent that a second code execution can be triggered while a first one is still running. These change applies to any form of code execution, including runs, score runs, test runs, submit requests, RfC requests.

With the changed stopCode function, switching from one execution mode to another (i.e., run to score or vice versa) will wait until the previous execution stopped. When the window is reloaded, either the execution stops immediately (run) or the backend lock mechanism for runners will still prevent duplicate executions (test, score, submit).

The changes in this commit further ensures that the same button cannot be pressed twice. For example, a double-click on Run would previously schedule two executions, which might interfere with each other (or simply produce the "runner in use" message which is still annoying).