Slow down successive exercise execution via debounce #814
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a new option
tutorial.exercise.debounce
to slow down successive exercise evaluations.I've noticed that you can overwhelm a server that hosts a learnr tutorial by repeatedly clicking "Run Code" very quickly in an exercise chunk. On the Linux server that I'm using, this causes learnr to run a new R instance for each evaluation, amounting to hundreds or thousands of instances, depending on how quick you can click and how fast the server can execute and tear down again the R instances.
My fix introduces the use of debounce() when the option is active.
Use
options("tutorial.exercise.debounce" = 1000)
in a setup chunk of an Rmarkdown document to enable a debounce of 1 sec. The default value is 0, which keeps the behavior currently implemented in learnr (i.e. no debounce).This is my first contribution here, I'm not quite sure if I've updated the documentation at the correct spot.
PR task list:
devtools::document()