Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow down successive exercise execution via debounce #814

Closed

Conversation

internaut
Copy link
Contributor

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:

  • Update NEWS
  • Update documentation with devtools::document()

@CLAassistant
Copy link

CLAassistant commented May 31, 2024

CLA assistant check
All committers have signed the CLA.

@andreebee
Copy link

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

NEWS.md Show resolved Hide resolved
pkgdown/assets/snippets/exercisedebounce.md Show resolved Hide resolved
pkgdown/assets/snippets/exercisedebounce.md Show resolved Hide resolved
R/exercise.R Show resolved Hide resolved
vignettes/articles/exercises.Rmd Show resolved Hide resolved
@schloerke
Copy link
Collaborator

Thank you for the PR!

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

@schloerke schloerke closed this Sep 4, 2024
@gadenbuie
Copy link
Member

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.

@internaut
Copy link
Contributor Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants