-
Notifications
You must be signed in to change notification settings - Fork 35
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
evaluate("sink(...)")
crashes the R session
#104
Comments
Would someone be able to triage this? |
We can definitely throw an error if |
In my specific use case we would also need to modify |
Another option would be to override There's already an existing mechanism for this in |
I'm not 100% convinced that silently restoring the sink + connection is the correct approach, but it doesn't happen very often and we aren't going to lose much output if we immediately re-open the sink + connection. Fixes #104 (at least as much as it can be fixed)
Context
I am writing a package that implements a standardized logging function using
sink(...)
. I would like to be able to use RMarkdown to write the vignettes for the package. However, my functions do not execute correctly when rendering the Rmd files due toevaluate
's treatment of thesink
commands passed in byrmarkdown::render
.Issue
The use of
sink(...)
withinevaluate()
crashes the R session. The function should provide similar behavior toeval(parse(text='sink(...)'))
which, correctly, executes thesink()
command and returns no other output. Alternately, because this is difficult to resolve,evaluate()
could return an error or a warning which could be handled by other consumers ofevaluate
, particularlyrmarkdown::render
. An easy way to catch this issue would be to observe if new connections were added or ifsink.number()
increased within thew$close
function returned bywatchout()
.Reprex
evaluate("sink('temp.txt')")
produces:Error: invalid connection
, and no commands will execute until the R session is restarted.sessionInfo()
The text was updated successfully, but these errors were encountered: