learnr icon indicating copy to clipboard operation
learnr copied to clipboard

Slow down successive exercise execution via debounce

Open internaut opened this issue 1 year ago • 1 comments
trafficstars

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:

  • [x] Update NEWS
  • [x] Update documentation with devtools::document()

internaut avatar May 31 '24 12:05 internaut

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar May 31 '24 12:05 CLAassistant

As this issue is security-related, it would be great if the pull-request could be reviewed. Thank you very much.

andreebee avatar Sep 03 '24 16:09 andreebee

Thank you for the PR!

I'm closing this PR in favor of #818 as I can not apply suggestions (weird!)

schloerke avatar Sep 04 '24 14:09 schloerke

I'm closing this PR in favor of #818 as I can not apply suggestions (weird!)

The PR was opened without the "Allow maintainers to edit this PR" option selected.

gadenbuie avatar Sep 04 '24 14:09 gadenbuie

The PR was opened without the "Allow maintainers to edit this PR" option selected.

Sorry, that was not on purpose, must have missed it.

Thanks for considering this patch!

internaut avatar Sep 05 '24 08:09 internaut